本文整理汇总了C#中Section.AddParagraph方法的典型用法代码示例。如果您正苦于以下问题:C# Section.AddParagraph方法的具体用法?C# Section.AddParagraph怎么用?C# Section.AddParagraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section.AddParagraph方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendBulletedList
private void AppendBulletedList(Section section)
{
Paragraph paragraph = null;
paragraph = section.AddParagraph();
//Append Text
paragraph.AppendText("Bulleted List");
paragraph.ApplyStyle(BuiltinStyle.Heading3);
paragraph = section.AddParagraph();
for (int i = 0; i < 5; i++)
{
paragraph = section.AddParagraph();
paragraph.AppendText("Item" + i.ToString());
if (i == 0)
{
paragraph.ListFormat.ApplyBulletStyle();
}
else
{
paragraph.ListFormat.ContinueListNumbering();
}
paragraph.ListFormat.ListLevelNumber = 1;
}
}
示例2: InsertImage
private void InsertImage(Section section)
{
Paragraph paragraph
= section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
paragraph.AppendText("The sample demonstrates how to insert a image into a document.");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = section.AddParagraph();
paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left;
paragraph.AppendPicture(Image.Properties.Resources.Word);
}
示例3: InsertTextbox
private void InsertTextbox(Section section)
{
Paragraph paragraph
= section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
paragraph.AppendText("The sample demonstrates how to insert a textbox into a document.");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = section.AddParagraph();
paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left;
Spire.Doc.Fields.TextBox textBox = paragraph.AppendTextBox(50,20);
}
示例4: AppendIndentationText
private void AppendIndentationText(Section section)
{
Paragraph paragraph = null;
paragraph = section.AddParagraph();
//Append Text
paragraph.AppendText("Indentation");
paragraph.ApplyStyle(BuiltinStyle.Heading3);
paragraph = section.AddParagraph();
paragraph.AppendText("Indentation is the spacing between text and margins. Word allows you to set left and right margins, as well as indentations for the first line of a paragraph and hanging indents");
paragraph.Format.FirstLineIndent = 15;
}
示例5: AppendAligmentText
private void AppendAligmentText(Section section)
{
Paragraph paragraph = null;
paragraph = section.AddParagraph();
//Append Text
paragraph.AppendText("Horizontal Aligenment");
paragraph.ApplyStyle(BuiltinStyle.Heading3);
foreach (Spire.Doc.Documents.HorizontalAlignment align in Enum.GetValues(typeof(Spire.Doc.Documents.HorizontalAlignment)))
{
Paragraph paramgraph = section.AddParagraph();
paramgraph.AppendText("This text is " + align.ToString());
paramgraph.Format.HorizontalAlignment = align;
}
}
示例6: InsertHyberlink
private void InsertHyberlink(Section section)
{
Paragraph paragraph
= section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
paragraph.AppendText("Spire.XLS for .NET \r\n e-iceblue company Ltd. 2002-2010 All rights reserverd");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = section.AddParagraph();
paragraph.AppendText("Home page");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = section.AddParagraph();
paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);
paragraph = section.AddParagraph();
paragraph.AppendText("Contact US");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
paragraph = section.AddParagraph();
paragraph.AppendHyperlink("mailto:[email protected]", "[email protected]", HyperlinkType.EMailLink);
}
示例7: InsertContent
private void InsertContent(Section section)
{
ParagraphStyle list = new ParagraphStyle(section.Document);
list.Name = "list";
list.CharacterFormat.FontName = "Arial";
list.CharacterFormat.FontSize = 11;
list.ParagraphFormat.LineSpacing = 1.5F * 12F;
list.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
section.Document.Styles.Add(list);
Paragraph title = section.AddParagraph();
//next page
title.AppendBreak(BreakType.PageBreak);
TextRange text = title.AppendText("Field type list:");
title.ApplyStyle(list.Name);
bool first = true;
foreach (FieldType type in Enum.GetValues(typeof(FieldType)))
{
if (type == FieldType.FieldUnknown
|| type == FieldType.FieldNone || type == FieldType.FieldEmpty)
{
continue;
}
Paragraph paragraph = section.AddParagraph();
paragraph.AppendText(String.Format("{0} is supported in Spire.Doc", type));
if (first)
{
paragraph.ListFormat.ApplyNumberedStyle();
first = false;
}
else
{
paragraph.ListFormat.ContinueListNumbering();
}
paragraph.ApplyStyle(list.Name);
}
}
示例8: InsertWatermark
private void InsertWatermark(Section section)
{
Paragraph paragraph
= section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
paragraph.AppendText("The sample demonstrates how to insert a watermark into a document.");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
TextWatermark txtWatermark = new TextWatermark();
txtWatermark.Text = "Watermark Demo";
txtWatermark.FontSize = 90;
txtWatermark.Layout = WatermarkLayout.Diagonal;
section.Document.Watermark = txtWatermark;
}
示例9: Bookmark
private void Bookmark(Section section)
{
Paragraph paragraph
= section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();
paragraph.AppendText("The sample demonstrates how to using bookmark.");
paragraph.ApplyStyle(BuiltinStyle.Heading2);
section.AddParagraph();
paragraph = section.AddParagraph();
paragraph.AppendText("Simple bookmark.");
paragraph.ApplyStyle(BuiltinStyle.Heading4);
// Writing simple bookmarks
section.AddParagraph();
paragraph = section.AddParagraph();
paragraph.AppendBookmarkStart("SimpleBookMark");
paragraph.AppendText("This is a simple book mark.");
paragraph.AppendBookmarkEnd("SimpleBookMark");
section.AddParagraph();
paragraph = section.AddParagraph();
paragraph.AppendText("Nested bookmark.");
paragraph.ApplyStyle(BuiltinStyle.Heading4);
// Writing nested bookmarks
section.AddParagraph();
paragraph = section.AddParagraph();
paragraph.AppendBookmarkStart("Root");
paragraph.AppendText(" Root data ");
paragraph.AppendBookmarkStart("NestedLevel1");
paragraph.AppendText(" Nested Level1 ");
paragraph.AppendBookmarkStart("NestedLevel2");
paragraph.AppendText(" Nested Level2 ");
paragraph.AppendBookmarkEnd("NestedLevel2");
paragraph.AppendText(" Data Level1 ");
paragraph.AppendBookmarkEnd("NestedLevel1");
paragraph.AppendText(" Data Root ");
paragraph.AppendBookmarkEnd("Root");
}
示例10: InsertCover
private void InsertCover(Section section)
{
ParagraphStyle small = new ParagraphStyle(section.Document);
small.Name = "small";
small.CharacterFormat.FontName = "Arial";
small.CharacterFormat.FontSize = 9;
small.CharacterFormat.TextColor = Color.Gray;
section.Document.Styles.Add(small);
Paragraph paragraph = section.AddParagraph();
paragraph.AppendText("The sample demonstrates how to insert a header and footer into a document.");
paragraph.ApplyStyle(small.Name);
Paragraph title = section.AddParagraph();
TextRange text = title.AppendText("Field Types Supported by Spire.Doc");
text.CharacterFormat.FontName = "Arial";
text.CharacterFormat.FontSize = 36;
text.CharacterFormat.Bold = true;
title.Format.BeforeSpacing
= section.PageSetup.PageSize.Height / 2 - 3 * section.PageSetup.Margins.Top;
title.Format.AfterSpacing = 8;
title.Format.HorizontalAlignment
= Spire.Doc.Documents.HorizontalAlignment.Right;
paragraph = section.AddParagraph();
paragraph.AppendText("e-iceblue Spire.Doc team.");
paragraph.ApplyStyle(small.Name);
paragraph.Format.HorizontalAlignment
= Spire.Doc.Documents.HorizontalAlignment.Right;
}
示例11: AddForm
private void AddForm(Section section)
{
ParagraphStyle descriptionStyle = new ParagraphStyle(section.Document);
descriptionStyle.Name = "description";
descriptionStyle.CharacterFormat.FontSize = 12;
descriptionStyle.CharacterFormat.FontName = "Arial";
descriptionStyle.CharacterFormat.TextColor = Color.FromArgb(0x00, 0x45, 0x8e);
section.Document.Styles.Add(descriptionStyle);
Paragraph p1 = section.AddParagraph();
String text1
= "So that we can verify your identity and find your information, "
+ "please provide us with the following information. "
+ "This information will be used to create your online account. "
+ "Your information is not public, shared in anyway, or displayed on this site";
p1.AppendText(text1);
p1.ApplyStyle(descriptionStyle.Name);
Paragraph p2 = section.AddParagraph();
String text2
= "You must provide a real email address to which we will send your password.";
p2.AppendText(text2);
p2.ApplyStyle(descriptionStyle.Name);
p2.Format.AfterSpacing = 8;
//field group label style
ParagraphStyle formFieldGroupLabelStyle = new ParagraphStyle(section.Document);
formFieldGroupLabelStyle.Name = "formFieldGroupLabel";
formFieldGroupLabelStyle.ApplyBaseStyle("description");
formFieldGroupLabelStyle.CharacterFormat.Bold = true;
formFieldGroupLabelStyle.CharacterFormat.TextColor = Color.White;
section.Document.Styles.Add(formFieldGroupLabelStyle);
//field label style
ParagraphStyle formFieldLabelStyle = new ParagraphStyle(section.Document);
formFieldLabelStyle.Name = "formFieldLabel";
formFieldLabelStyle.ApplyBaseStyle("description");
formFieldLabelStyle.ParagraphFormat.HorizontalAlignment
= Spire.Doc.Documents.HorizontalAlignment.Right;
section.Document.Styles.Add(formFieldLabelStyle);
//add table
Table table = section.AddTable();
//2 columns of per row
table.DefaultColumnsNumber = 2;
//default height of row is 20point
table.DefaultRowHeight = 20;
//load form config data
using (Stream stream = File.OpenRead(@"..\..\..\..\..\..\Data\Form.xml"))
{
XPathDocument xpathDoc = new XPathDocument(stream);
XPathNodeIterator sectionNodes = xpathDoc.CreateNavigator().Select("/form/section");
foreach (XPathNavigator node in sectionNodes)
{
//create a row for field group label, does not copy format
TableRow row = table.AddRow(false);
row.Cells[0].CellFormat.BackColor = Color.FromArgb(0x00, 0x71, 0xb6);
row.Cells[0].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
//label of field group
Paragraph cellParagraph = row.Cells[0].AddParagraph();
cellParagraph.AppendText(node.GetAttribute("name", ""));
cellParagraph.ApplyStyle(formFieldGroupLabelStyle.Name);
XPathNodeIterator fieldNodes = node.Select("field");
foreach (XPathNavigator fieldNode in fieldNodes)
{
//create a row for field, does not copy format
TableRow fieldRow = table.AddRow(false);
//field label
fieldRow.Cells[0].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
Paragraph labelParagraph = fieldRow.Cells[0].AddParagraph();
labelParagraph.AppendText(fieldNode.GetAttribute("label", ""));
labelParagraph.ApplyStyle(formFieldLabelStyle.Name);
fieldRow.Cells[1].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
Paragraph fieldParagraph = fieldRow.Cells[1].AddParagraph();
String fieldId = fieldNode.GetAttribute("id", "");
switch (fieldNode.GetAttribute("type", ""))
{
case "text":
//add text input field
TextFormField field
= fieldParagraph.AppendField(fieldId, FieldType.FieldFormTextInput) as TextFormField;
//set default text
field.DefaultText = "";
field.Text = "";
break;
case "list":
//add dropdown field
DropDownFormField list
= fieldParagraph.AppendField(fieldId, FieldType.FieldFormDropDown) as DropDownFormField;
//add items into dropdown.
//.........这里部分代码省略.........
示例12: AddTitle
private void AddTitle(Section section)
{
Paragraph title = section.AddParagraph();
TextRange titleText = title.AppendText("Create Your Account");
titleText.CharacterFormat.FontSize = 18;
titleText.CharacterFormat.FontName = "Arial";
titleText.CharacterFormat.TextColor = Color.FromArgb(0x00, 0x71, 0xb6);
title.Format.HorizontalAlignment
= Spire.Doc.Documents.HorizontalAlignment.Center;
title.Format.AfterSpacing = 8;
}
示例13: InsertContent
private void InsertContent(Section section)
{
//title
Paragraph paragraph = section.AddParagraph();
TextRange title = paragraph.AppendText("Summary of Science");
title.CharacterFormat.Bold = true;
title.CharacterFormat.FontName = "Arial";
title.CharacterFormat.FontSize = 14;
paragraph.Format.HorizontalAlignment
= Spire.Doc.Documents.HorizontalAlignment.Center;
paragraph.Format.AfterSpacing = 10;
//style
ParagraphStyle style1 = new ParagraphStyle(section.Document);
style1.Name = "style1";
style1.CharacterFormat.FontName = "Arial";
style1.CharacterFormat.FontSize = 9;
style1.ParagraphFormat.LineSpacing = 1.5F * 12F;
style1.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
section.Document.Styles.Add(style1);
ParagraphStyle style2 = new ParagraphStyle(section.Document);
style2.Name = "style2";
style2.ApplyBaseStyle(style1.Name);
style2.CharacterFormat.Font = new Font("Arial", 10f);
section.Document.Styles.Add(style2);
paragraph = section.AddParagraph();
paragraph.AppendText("(All text and pictures are from ");
String link = "http://en.wikipedia.org/wiki/Science";
paragraph.AppendHyperlink(link, "Wikipedia", HyperlinkType.WebLink);
paragraph.AppendText(", the free encyclopedia)");
paragraph.ApplyStyle(style1.Name);
Paragraph paragraph1 = section.AddParagraph();
String str1
= "Science (from the Latin scientia, meaning \"knowledge\") "
+ "is an enterprise that builds and organizes knowledge in the form "
+ "of testable explanations and predictions about the natural world. "
+ "An older meaning still in use today is that of Aristotle, "
+ "for whom scientific knowledge was a body of reliable knowledge "
+ "that can be logically and rationally explained "
+ "(see \"History and etymology\" section below).";
paragraph1.AppendText(str1);
//Insert a picture in the right of the paragraph1
DocPicture picture
= paragraph1.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\Data\Wikipedia_Science.png"));
picture.TextWrappingStyle = TextWrappingStyle.Square;
picture.TextWrappingType = TextWrappingType.Left;
picture.VerticalOrigin = VerticalOrigin.Paragraph;
picture.VerticalPosition = 0;
picture.HorizontalOrigin = HorizontalOrigin.Column;
picture.HorizontalAlignment = ShapeHorizontalAlignment.Right;
paragraph1.ApplyStyle(style2.Name);
Paragraph paragraph2 = section.AddParagraph();
String str2
= "Since classical antiquity science as a type of knowledge was closely linked "
+ "to philosophy, the way of life dedicated to discovering such knowledge. "
+ "And into early modern times the two words, \"science\" and \"philosophy\", "
+ "were sometimes used interchangeably in the English language. "
+ "By the 17th century, \"natural philosophy\" "
+ "(which is today called \"natural science\") could be considered separately "
+ "from \"philosophy\" in general. But \"science\" continued to also be used "
+ "in a broad sense denoting reliable knowledge about a topic, in the same way "
+ "it is still used in modern terms such as library science or political science.";
paragraph2.AppendText(str2);
paragraph2.ApplyStyle(style2.Name);
Paragraph paragraph3 = section.AddParagraph();
String str3
= "The more narrow sense of \"science\" that is common today developed as a part "
+ "of science became a distinct enterprise of defining \"laws of nature\", "
+ "based on early examples such as Kepler's laws, Galileo's laws, and Newton's "
+ "laws of motion. In this period it became more common to refer to natural "
+ "philosophy as \"natural science\". Over the course of the 19th century, the word "
+ "\"science\" became increasingly associated with the disciplined study of the "
+ "natural world including physics, chemistry, geology and biology. This sometimes "
+ "left the study of human thought and society in a linguistic limbo, which was "
+ "resolved by classifying these areas of academic study as social science. "
+ "Similarly, several other major areas of disciplined study and knowledge "
+ "exist today under the general rubric of \"science\", such as formal science "
+ "and applied science.";
paragraph3.AppendText(str3);
paragraph3.ApplyStyle(style2.Name);
}