本文整理汇总了C#中TextDocument.New方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.New方法的具体用法?C# TextDocument.New怎么用?C# TextDocument.New使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextDocument
的用法示例。
在下文中一共展示了TextDocument.New方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NewTextDocument
public void NewTextDocument()
{
TextDocument td = new TextDocument();
td.New();
Assert.IsNotNull(td.XmlDoc, "Must exist!");
//Console.WriteLine("Doc: {0}", td.XmlDoc.OuterXml);
}
示例2: CellParagraphTest
public void CellParagraphTest()
{
TextDocument doc = new TextDocument();
doc.New();
Table table = new Table(doc, "table1");
table.Init(5, 3, 16.99);
foreach(Row r in table.Rows)
foreach(Cell c in r.Cells)
c.InsertText("Hello");
Paragraph p = new Paragraph(doc, "P1");
FormatedText ft = new FormatedText(p, "T1", "Hello World");
((TextStyle)ft.Style).Properties.Italic = "italic";
p.TextContent.Add(ft);
table.Rows[0].Cells[0].Content.Add(p);
doc.Content.Add(table);
doc.SaveTo("tablewithstyles.odt");
}
示例3: ParagraphAddRemoveTest
public void ParagraphAddRemoveTest()
{
TextDocument td = new TextDocument();
td.New();
Paragraph p = new Paragraph(td, "P1");
Assert.IsNotNull(p.Style, "Style object must exist!");
Assert.AreEqual(p.Style.GetType().Name, "ParagraphStyle", "IStyle object must be type of ParagraphStyle");
Assert.IsNotNull(((ParagraphStyle)p.Style).Properties, "Properties object must exist!");
//add text
p.TextContent.Add(new SimpleText(p, "Hello"));
IText itext = p.TextContent[0];
p.TextContent.Remove(itext);
//Console.Write(p.Node.Value);
Assert.IsTrue(p.Node.InnerXml.IndexOf("Hello") == -1, "Must be removed!");
//Add the Paragraph
td.Content.Add((IContent)p);
//Blank para
td.Content.Add(new Paragraph(td, ParentStyles.Standard.ToString()));
// new para
p = new Paragraph(td, "P2");
p.TextContent.Add(new SimpleText(p, "Hello i'm still here"));
td.Content.Add(p);
td.SaveTo("pararemoved.odt");
//Console.WriteLine("Document: {0}", td.XmlDoc.OuterXml);
}
示例4: CellSpanTest
public void CellSpanTest()
{
TextDocument doc = new TextDocument();
doc.New();
Table table = new Table(doc, "table1");
table.Init(5, 2, 16.99);
//Create a new row within this table and
//set the cellspan to 2
Row row = new Row(table, "");
//Create a real cell
Cell cell = new Cell(row, "table1.ZZ1");
//Set cell span
cell.ColumnRepeating = "2";
//Set the border
((CellStyle)cell.Style).CellProperties.Border = Border.NormalSolid;
//add some content to this cell
cell.Content.Add(new Paragraph(doc,
ParentStyles.Standard,
"Hello I'm merged over two cells!"));
//add cell to the row
row.Cells.Add(cell);
//we have to add one CellSpan object, because the
//table has original 2 columns
row.CellSpans.Add(new CellSpan(row));
//at least at this row the table
table.Rows.Add(row);
//add the table to the document
doc.Content.Add(table);
//save it to the disk
doc.SaveTo("tablecellspan.odt");
}
示例5: ParagraphTest
public void ParagraphTest()
{
TextDocument td = new TextDocument();
td.New();
Paragraph p = new Paragraph(td, "P1");
Assert.IsNotNull(p.Style, "Style object must exist!");
Assert.AreEqual(p.Style.GetType().Name, "ParagraphStyle", "IStyle object must be type of ParagraphStyle");
Assert.IsNotNull(((ParagraphStyle)p.Style).Properties, "Properties object must exist!");
//add text
p.TextContent.Add(new SimpleText(p, "HallO"));
//Add the Paragraph
td.Content.Add((IContent)p);
//Blank para
td.Content.Add(new Paragraph(td, ParentStyles.Standard.ToString()));
// new para
p = new Paragraph(td, "P2");
p.TextContent.Add(new SimpleText(p, "Hallo"));
td.Content.Add(p);
td.SaveTo("parablank.odt");
//Console.WriteLine("Document: {0}", td.XmlDoc.OuterXml);
}
示例6: RowHeaderTest
public void RowHeaderTest()
{
TextDocument doc = new TextDocument();
doc.New();
Table table = new Table(doc, "table1");
table.Init(5, 2, 16.99, true);
//Set the row header
if(table.RowHeader != null)
{
//Headline
table.RowHeader.RowCollection[0].Cells[0].InsertText("Application");
table.RowHeader.RowCollection[0].Cells[1].InsertText("Short cut");
}
foreach(Row r in table.Rows)
foreach(Cell c in r.Cells)
c.InsertText("Hello");
doc.Content.Add(table);
doc.SaveTo("tableheader.odt");
}
示例7: MergeCellsTest
public void MergeCellsTest()
{
TextDocument doc = new TextDocument();
doc.New();
Table table = new Table(doc, "table1");
table.Init(4, 5, 16.99);
foreach(Row r in table.Rows)
foreach(Cell c in r.Cells)
c.InsertText("Hello");
//Merge the first cell of the first row and set mergeContent, so
//all content from the merged cells will move
//to the first unmerged cell
table.Rows[0].MergeCells(0, 3, true);
//Merge the first cell of the third row
//set mergeContent and merge all cells
//The result will be that row 3 only have one cell!
table.Rows[2].MergeCells(0, 5, true);
doc.Content.Add(table);
doc.SaveTo("tablemergedcell.odt");
}
示例8: LongTableTest
public void LongTableTest()
{
TextDocument doc = new TextDocument();
doc.New();
Table table = new Table(doc, "table1");
table.Init(150, 5, 16.99);
foreach(Row r in table.Rows)
foreach(Cell c in r.Cells)
c.InsertText("Hello");
doc.Content.Add(table);
doc.SaveTo("tablelong.odt");
}
示例9: WhiteSpaceTest
public void WhiteSpaceTest()
{
//Create new TextDocument
TextDocument document = new TextDocument();
document.New();
//Create a new Paragraph
Paragraph para = new Paragraph(document, "P1");
//Create some simple text with whitespaces
SimpleText stext = new SimpleText(para, "Some simple text add 12 whitespace \"and go on.");
//Add the textcontent
para.TextContent.Add(stext);
//Add paragraph to the document content
document.Content.Add(para);
//Save
document.SaveTo("Whitespaces.odt");
}
示例10: TabstopTest
public void TabstopTest()
{
//Create new document
TextDocument document = new TextDocument();
document.New();
//Create new paragraph
Paragraph par = new Paragraph(document, "P1");
//Create a new TabStopStyle collection
TabStopStyleCollection tsc = new TabStopStyleCollection(document);
//Create TabStopStyles
TabStopStyle ts = new TabStopStyle(document, 4.98);
ts.LeaderStyle = TabStopLeaderStyles.Dotted;
ts.LeaderText = ".";
ts.Type = TabStopTypes.Center;
//Add the tabstop
tsc.Add(ts);
//Append the TabStopStyleCollection
((ParagraphStyle)par.Style).Properties.TabStopStyleCollection = tsc;
//Add some text, use @ qualifier when ever you use control chars!
string mytebstoptext = @"Hello\tHello again";
SimpleText stext = new SimpleText(par, mytebstoptext);
//the simple text
par.TextContent.Add(stext);
//Add the paragraph to the content container
document.Content.Add(par);
//Save
document.SaveTo("tabstop.odt");
}
示例11: FooterAndHeader
public void FooterAndHeader()
{
//Create a new document
TextDocument td = new TextDocument();
td.New();
//Create a new paragraph
Paragraph p = new Paragraph(td, "P1");
//Create some formated text
FormatedText ftext = new FormatedText(p, "F1", "Im the Header");
((TextStyle)ftext.Style).Properties.Italic = "italic";
//add the text
p.TextContent.Add(ftext);
//Insert paragraph as header
td.InsertHeader(p);
//New paragraph
p = new Paragraph(td, ParentStyles.Standard,
"I'm the Footer");
//Insert paragraph as footer
td.InsertFooter(p);
//Save
td.SaveTo("Header_Footer.odt");
}
示例12: NewTextAndParagraphProps
public void NewTextAndParagraphProps()
{
//Create a new TextDocument
TextDocument document = new TextDocument();
document.New();
//Create new Paragraph
Paragraph paragraph = new Paragraph(document, "P1");
//Create paragraph border
((ParagraphStyle)paragraph.Style).Properties.Border =
Border.MiddleSolid;
//Set line spacing to double
((ParagraphStyle)paragraph.Style).Properties.LineSpacing =
ParagraphHelper.LineDouble;
//Create some formated text
FormatedText ftext = new FormatedText(paragraph, "T1", @"Outline\n");
//Set text as Outline
((TextStyle)ftext.Style).Properties.Outline = "true";
//Add to paragraph
paragraph.TextContent.Add(ftext);
//Create some formated text
ftext = new FormatedText(paragraph, "T2", @"Colored\n");
//Set font color
((TextStyle)ftext.Style).Properties.FontColor = Colors.GetColor(System.Drawing.Color.Cyan);
//Add to paragraph
paragraph.TextContent.Add(ftext);
//Create some formated text
ftext = new FormatedText(paragraph, "T3", @"Backcolor\n");
//Set background color
((TextStyle)ftext.Style).Properties.BackgroundColor = Colors.GetColor(System.Drawing.Color.Cyan);
//Add to paragraph
paragraph.TextContent.Add(ftext);
//Create some formated text
ftext = new FormatedText(paragraph, "T4", @"Shadow\n");
//Set shadow
((TextStyle)ftext.Style).Properties.Shadow = TextPropertieHelper.Shadowmidlle;
//Add to paragraph
paragraph.TextContent.Add(ftext);
//Create some formated text
ftext = new FormatedText(paragraph, "T5", @"Subscript\n");
//Set subscript
((TextStyle)ftext.Style).Properties.Position = TextPropertieHelper.Subscript;
//Add to paragraph
paragraph.TextContent.Add(ftext);
//Create some formated text
ftext = new FormatedText(paragraph, "T6", @"Superscript\n");
//Set superscript
((TextStyle)ftext.Style).Properties.Position = TextPropertieHelper.Superscript;
//Add to paragraph
paragraph.TextContent.Add(ftext);
//Create some formated text
ftext = new FormatedText(paragraph, "T7", @"Strice through\n");
//Set superscript
((TextStyle)ftext.Style).Properties.TextLineThrough = LineStyles.solid;
//Add to paragraph
paragraph.TextContent.Add(ftext);
//finally add paragraph to the document
document.Content.Add(paragraph);
//Save the document
document.SaveTo("NewProperties.odt");
}
示例13: FootnoteText
public void FootnoteText()
{
//Create new TextDocument
TextDocument document = new TextDocument();
document.New();
//Create a new Paragph
Paragraph para = new Paragraph(document, "P1");
//Create some simple Text
SimpleText stext = new SimpleText(para, "Some simple text. And I have a footnode");
//Create a Footnote
Footnote fnote = new Footnote(para, "Footer \" Text", "1", FootnoteType.footnode);
//Add the text content
para.TextContent.Add(stext);
para.TextContent.Add(fnote);
//Add the paragraph
document.Content.Add(para);
//Save
document.SaveTo("footnote.odt");
}
示例14: XLinkTest
public void XLinkTest()
{
//Create new TextDocument
TextDocument document = new TextDocument();
document.New();
//Create a new Paragraph
Paragraph para = new Paragraph(document, "P1");
//Create some simple text
SimpleText stext = new SimpleText(para, "Some simple text");
//Create a XLink
XLink xlink = new XLink(para, "http://www.sourceforge.net", "Sourceforge");
//Add the textcontent
para.TextContent.Add(stext);
para.TextContent.Add(xlink);
//Add paragraph to the document content
document.Content.Add(para);
//Save
document.SaveTo("XLink.odt");
}
示例15: BookmarkTest
public void BookmarkTest()
{
//Create a new TextDocument
TextDocument document = new TextDocument();
document.New();
//Create a new Paragraph
Paragraph para = new Paragraph(document, "P1");
//Create simple text
SimpleText stext = new SimpleText(para, "Some text here");
//add the simple text
para.TextContent.Add(stext);
//add the paragraph
document.Content.Add(para);
//add a blank paragraph
document.Content.Add(new Paragraph(document, ParentStyles.Standard.ToString()));
//Create a new Paragraph
para = new Paragraph(document, "P2");
//add some simple text
para.TextContent.Add(new SimpleText(para, "some simple text"));
//create a new standard bookmark
Bookmark bookmark = new Bookmark(para, BookmarkType.Standard, "address");
//add bookmark to the paragraph
para.TextContent.Add(bookmark);
//add the paragraph to the document
document.Content.Add(para);
//create a paragraph, with a bookmark range Start -> End
para = new Paragraph(document, "P3");
bookmark = new Bookmark(para, BookmarkType.Start, "address2");
//add bookmark to the paragraph
para.TextContent.Add(bookmark);
//add some simple text
para.TextContent.Add(new SimpleText(para, "more text"));
//create a new end bookmark
bookmark = new Bookmark(para, BookmarkType.End, "address2");
//add bookmark to the paragraph, so the encapsulated bookmark text is "more text"
para.TextContent.Add(bookmark);
//add the paragraph to the document content
document.Content.Add(para);
//save
document.SaveTo("bookmark.odt");
}