本文整理汇总了C#中TextDocument.SaveTo方法的典型用法代码示例。如果您正苦于以下问题:C# TextDocument.SaveTo方法的具体用法?C# TextDocument.SaveTo怎么用?C# TextDocument.SaveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextDocument
的用法示例。
在下文中一共展示了TextDocument.SaveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Howto_special_char
public void Howto_special_char()
{
TextDocument document = new TextDocument();
document.Load("Howto_special_char.odt");
document.SaveTo("Howto_special_char.html");
document.Dispose();
}
示例2: 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");
}
示例3: Howto_special_charInch
public void Howto_special_charInch()
{
TextDocument document = new TextDocument();
document.Load(@"F:\odtFiles\Howto_special_char.odt");
document.SaveTo(@"F:\odtFiles\Howto_special_char.html");
document.Dispose();
}
示例4: 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");
}
示例5: ReloadHeader
public void ReloadHeader()
{
TestClass test = new TestClass();
test.HeadingsTest();
TextDocument doc = new TextDocument();
doc.Load("Heading.odt");
doc.SaveTo("HeadingReloaded.odt");
doc.Dispose();
}
示例6: ComplexTable
public void ComplexTable()
{
TableTest tableTest = new TableTest();
tableTest.MergeCellsTest();
TextDocument doc = new TextDocument();
doc.Load("tablemergedcell.odt");
doc.SaveTo("tablemergedcellReloaded.odt");
doc.Dispose();
}
示例7: ProgrammaticControl
public void ProgrammaticControl()
{
TextDocument document = new TextDocument();
document.Load("ProgrammaticControlOfMenuAndToolbarItems.odt");
document.SaveTo("ProgrammaticControlOfMenuAndToolbarItems.html");
// document.Load("AndrewMacroPart.odt");
// document.SaveTo("AndrewMacro.html");
// document.Load("OfferLongVersion.odt");
// document.SaveTo("OfferLongVersion.html");
document.Dispose();
}
示例8: 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);
}
示例9: ParagraphTextPropertiesTest
public void ParagraphTextPropertiesTest()
{
TextDocument td = new TextDocument();
td.New();
Paragraph p = new Paragraph(td, "P1");
//justify
((ParagraphStyle)p.Style).Properties.Alignment = TextAlignments.justify.ToString();
//Set complet paragraph to italic
((ParagraphStyle)p.Style).Textproperties.Italic = "italic";
((ParagraphStyle)p.Style).Textproperties.FontName = FontFamilies.BroadwayBT;
((ParagraphStyle)p.Style).Textproperties.FontSize = "18pt";
//add simple text
// use \n to insert a linebreak !!
p.TextContent.Add( new SimpleText(p, @"A \nloooooooooooooooooooooooooooooooooooooooong texxxxxxxxxxxxxxxt. A reaaaaaaaaaaalllly looooooooong teeeeeeeeeexxxxxxt"));
//add paragraph
td.Content.Add(p);
//Blank paragraph
Paragraph p2 = new Paragraph(td, "P2");
p2.TextContent.Add(new SimpleText(p2, ""));
td.Content.Add(p2);
Paragraph p3 = new Paragraph(td, "P3");
p3.TextContent.Add(new SimpleText(p3, "Hello"));
td.Content.Add(p3);
td.SaveTo("ParagraphTextProp.odt");
}
示例10: LetterTestShortVersion
public void LetterTestShortVersion()
{
string[] address = new string[] {"Max Mustermann","Mustermann Str. 300","22222 Hamburg"};
string[] recipient = new string[] {"Heinz Willi", "Dorfstr. 1", @"22225 Hamburg\n\n"};
string betreff = @"Offer for 200 Intel Pentium 4 CPU's\n\n";
string bodyheader = "Dear Mr. Willi,";
string[] bodytext = new string[] {
@"thank you for your request. We can offer you the 200 Intel Pentium IV 3 Ghz CPU's for a price of 79,80 € per unit.",
@"This special offer is valid to 31.10.2005. If you accept, we can deliver within 24 hours.\n\n\n"
};
string regards = @"Best regards \nMax Mustermann";
TextDocument td = new TextDocument();
td.New();
for(int i=0; i < address.Length; i++)
td.Content.Add(new Paragraph(td, ParentStyles.Standard, address[i]));
td.Content.Add(new Paragraph(td, ParentStyles.Standard.ToString()));
for(int i=0; i < recipient.Length; i++)
td.Content.Add(new Paragraph(td, ParentStyles.Standard, recipient[i]));
td.Content.Add(new Paragraph(td, ParentStyles.Standard.ToString()));
td.Content.Add(new Paragraph(td, ParentStyles.Standard, betreff));
td.Content.Add(new Paragraph(td, ParentStyles.Standard, bodyheader));
for(int i=0; i < bodytext.Length; i++)
{
Paragraph p = new Paragraph(td, "Pb"+i.ToString());
((ParagraphStyle)p.Style).Properties.Alignment = TextAlignments.justify.ToString();
p.TextContent.Add(new SimpleText(p, bodytext[i]));
td.Content.Add(p);
}
td.Content.Add(new Paragraph(td, ParentStyles.Standard.ToString()));
td.Content.Add(new Paragraph(td, ParentStyles.Standard, regards));
td.SaveTo("OfferShortVersion.odt");
}
示例11: 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");
}
示例12: TableTest1
public void TableTest1()
{
TextDocument td = new TextDocument();
td.New();
Table t = new Table(td, "table1");
Assert.IsNotNull(t.Node, "Node must exist");
Assert.IsNotNull(t.Style, "Style must exist");
Assert.AreEqual("table1", t.Style.Name, "Name must be table1");
Assert.IsNotNull(((TableStyle)t.Style).Properties, "Must exist!");
Assert.AreEqual("16.99cm", ((TableStyle)t.Style).Properties.Width, "Must be the default 16.99cm");
t.Init(2, 2, 16.99);
Assert.IsNotNull(t.Columns, "Columncollection must exist!");
Assert.IsTrue(t.Columns.Count == 2, "Must be 2 columns!");
Assert.AreEqual("table1.A", t.Columns[0].Style.Name, "Must be table1.A!");
Assert.AreEqual("table1.B", t.Columns[1].Style.Name, "Must be table1.B!");
Assert.IsNotNull(t.Rows, "RowCollection must exist!");
Assert.IsTrue(t.Rows.Count == 2, "Must be 2 rows");
Assert.AreEqual("table1.1", t.Rows[0].Stylename, "Must be table1.1");
Assert.AreEqual("table1.2", t.Rows[1].Stylename, "Must be table1.2");
Assert.IsTrue(t.Rows[0].Cells.Count == 2, "Must be 2 Cells wihtin this row!");
Assert.AreEqual("table1.A11", t.Rows[0].Cells[0].Stylename, "Must be table1.A1");
foreach(Row r in t.Rows)
foreach(Cell c in r.Cells)
c.InsertText("Hallo");
foreach(Row r in t.Rows)
foreach(Cell c in r.Cells)
Assert.IsTrue(c.Content.Count == 1, "Must be all 1");
td.Content.Add(t);
td.SaveTo("table1.odt");
}
示例13: 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");
}
示例14: 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");
}
示例15: HeadingsTest
public void HeadingsTest()
{
//Create a new text document
TextDocument document = new TextDocument();
document.New();
//Create a new Heading
Header header = new Header(document, Headings.Heading, "\"I'm the\n first Headline!\"");
//Add header
document.Content.Add(header);
document.SaveTo("Heading.odt");
}