public SaveTo ( string filename ) : void | ||
filename | string | The filename. With or without full path. Without will save the file to application path! |
return | void |
public void ODFFrameTest() { //Create a new text document TextDocument document = new TextDocument(); document.New(); // Create a main paragraph Paragraph p =new Paragraph(document); // Create a main form ODFForm main_form = new ODFForm(document, "mainform"); main_form.Method = Method.Get; // Create a frame ODFFrame frm = new ODFFrame(main_form, p.Content, "frm", "5mm", "5mm", "5cm", "3cm"); frm.Label = "ODFFrame test"; // Add the frame to the form control list main_form.Controls.Add (frm); // Create a button ODFButton butt = new ODFButton(main_form, p.Content, "butt", "1cm", "15mm", "4cm", "1cm"); butt.Label = "A simple button :)"; // Add the button to the form control list main_form.Controls.Add (butt); // Add the forms to the document! document.Forms.Add(main_form); // Add the paragraph to the content list document.Content.Add(p); document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"frame_test.odt"); document.Load(AARunMeFirstAndOnce.outPutFolder+"frame_test.odt"); document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"frame_test2.odt"); }
void Example3() { string imagePath = @"Assets\ODFSample\Examples\example3.png"; TextDocument document = new TextDocument(); document.New(); //Create standard paragraph Paragraph paragraphOuter = ParagraphBuilder.CreateStandardTextParagraph(document); //Create the frame with graphic Frame frame = new Frame(document, "frame1", "graphic1", imagePath); //Create a Draw Area Rectangle DrawAreaRectangle drawAreaRec = new DrawAreaRectangle( document, "0cm", "0cm", "1.5cm", "2.5cm", null); drawAreaRec.Href = "http://OpenDocument4all.com"; //Create a Draw Area Circle DrawAreaCircle drawAreaCircle = new DrawAreaCircle( document, "4cm", "4cm", "1.5cm", null); drawAreaCircle.Href = "http://AODL.OpenDocument4all.com"; DrawArea[] drawArea = new DrawArea[2] { drawAreaRec, drawAreaCircle }; //Create a Image Map ImageMap imageMap = new ImageMap(document, drawArea); //Add Image Map to the frame frame.Content.Add(imageMap); //Add frame to paragraph paragraphOuter.Content.Add(frame); //Add paragraph to document document.Content.Add(paragraphOuter); //Save the document document.SaveTo(@"example3_simpleImageMap.odt"); }
void Example6() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a table for a text document using the TableBuilder Table table = TableBuilder.CreateTextDocumentTable( document, "table1", "table1", 3, 3, 16.99, false, false); //Fill the cells foreach (Row row in table.RowCollection) { foreach (Cell cell in row.CellCollection) { //Create a standard paragraph Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Cell text")); cell.Content.Add(paragraph); } } //Merge some cells. Notice this is only available in text documents! table.RowCollection[1].MergeCells(document, 1, 2, true); //Add table to the document document.Content.Add(table); //Save the document document.SaveTo("example6_simpleTableWithMergedCells.odt"); }
void Example10() { //some text e.g read from a TextBox string someText = "Max Mustermann\nMustermann Str. 300\n22222 Hamburg\n\n\n\n" + "Heinz Willi\nDorfstr. 1\n22225 Hamburg\n\n\n\n" + "Offer for 200 Intel Pentium 4 CPU's\n\n\n\n" + "Dear Mr. Willi,\n\n\n\n" + "thank you for your request. \tWe 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\n" + "Best regards \nMax Mustermann"; //Create new TextDocument TextDocument document = new TextDocument(); document.New(); //Use the ParagraphBuilder to split the string into ParagraphCollection ParagraphCollection pCollection = ParagraphBuilder.CreateParagraphCollection( document, someText, true, ParagraphBuilder.ParagraphSeperator); //Add the paragraph collection foreach (Paragraph paragraph in pCollection) document.Content.Add(paragraph); //save document.SaveTo("example10_Letter.odt"); }
void Example7() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a table for a text document using the TableBuilder Table table = TableBuilder.CreateTextDocumentTable( document, "table1", "table1", 3, 3, 16.99, false, false); //Create a standard paragraph Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some cell text")); //Insert paragraph into the first cell table.RowCollection[0].CellCollection[0].Content.Add(paragraph); //Add table to the document document.Content.Add(table); //Save the document document.SaveTo("example7_simpleTable.odt"); }
void Example4() { string imagePath = @"Assets\ODFSample\Examples\example3.png"; TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph pOuter = ParagraphBuilder.CreateStandardTextParagraph(textdocument); DrawTextBox drawTextBox = new DrawTextBox(textdocument); Frame frameTextBox = new Frame(textdocument, "fr_txt_box"); frameTextBox.DrawName = "fr_txt_box"; frameTextBox.ZIndex = "0"; Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); p.StyleName = "Illustration"; Frame frame = new Frame(textdocument, "frame1", "graphic1", imagePath); frame.ZIndex = "1"; p.Content.Add(frame); p.TextContent.Add(new SimpleText(textdocument, "Illustration")); drawTextBox.Content.Add(p); frameTextBox.SvgWidth = frame.SvgWidth; drawTextBox.MinWidth = frame.SvgWidth; drawTextBox.MinHeight = frame.SvgHeight; frameTextBox.Content.Add(drawTextBox); pOuter.Content.Add(frameTextBox); textdocument.Content.Add(pOuter); textdocument.SaveTo("example4_drawTextbox.odt"); }
public void CreateNewDocumentAndDoAPrintOut() { string fileToPrint = AARunMeFirstAndOnce.outPutFolder+"fileToPrint.odt"; //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some simple text!")); //Add the paragraph to the document document.Content.Add(paragraph); //Save empty document.SaveTo(fileToPrint); //Now print the new document via the OpenOfficeLib //Get the Component Context XComponentContext xComponentContext = Connector.GetComponentContext(); //Get a MultiServiceFactory XMultiServiceFactory xMultiServiceFactory = Connector.GetMultiServiceFactory(xComponentContext); //Get a Dektop instance XDesktop xDesktop = Connector.GetDesktop(xMultiServiceFactory); //Convert a windows path to an OpenOffice one fileToPrint = Component.PathConverter(fileToPrint); //Load the document you want to print XComponent xComponent = Component.LoadDocument( (XComponentLoader)xDesktop, fileToPrint, "_blank"); //Print the XComponent Printer.Print(xComponent); }
public void EmptyDocument() { //Create a new text document var document = new TextDocument(); document.New(); //Save empty document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"empty.odt"); }
public void HTMLExportTest2() { string file = AARunMeFirstAndOnce.inPutFolder+@"OpenOffice.net.odt"; FileInfo fInfo = new FileInfo(file); //Load a text document TextDocument textDocument = new TextDocument(); textDocument.Load(file); //Save it back again textDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".html"); }
public void SimpleTocLoadTest() { string file = AARunMeFirstAndOnce.inPutFolder+@"simple_toc.odt"; FileInfo fInfo = new FileInfo(file); //Load a text document TextDocument textDocument = new TextDocument(); textDocument.Load(file); //Save it back again textDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".rel.odt"); }
void Example5() { TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); Frame frame = new Frame(textdocument, "frame1", "graphic1", @"Assets\ODFSample\Examples\example3.png"); p.Content.Add(frame); textdocument.Content.Add(p); textdocument.SaveTo("example5_grapic.odt"); }
public void GraphicsTest() { TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); Frame frame = new Frame(textdocument, "frame1", "graphic1", _imagefile); p.Content.Add(frame); textdocument.Content.Add(p); textdocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+"grapic.odt"); }
public void SimpleLoadTest() { string file = AARunMeFirstAndOnce.inPutFolder+@"hallo.odt"; FileInfo fInfo = new FileInfo(file); //Load a text document TextDocument textDocument = new TextDocument(); textDocument.Load(file); Assert.IsTrue(textDocument.CommonStyles.Count > 0, "Common Styles must be read!"); Console.WriteLine("Common styles: {0}", textDocument.CommonStyles.Count); //Save it back again textDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".rel.odt"); }
void Example16() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some simple text!")); //Add the paragraph to the document document.Content.Add(paragraph); //Save document.SaveTo("example16_simple.odt"); }
public void ParagraphSimpleText() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some simple text paragraph.TextContent.Add(new SimpleText(document, "Some simple text!")); //Add the paragraph to the document document.Content.Add(paragraph); //Save empty document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"simple.odt"); }
void Example15() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some formated text FormatedText formText = new FormatedText(document, "T1", "Some formated text!"); formText.TextStyle.TextProperties.Bold = "bold"; paragraph.TextContent.Add(formText); //Add the paragraph to the document document.Content.Add(paragraph); //Save document.SaveTo("example15_formated.odt"); }
void Example11() { //Create new TextDocument TextDocument document = new TextDocument(); document.New(); //Create a new Paragph Paragraph para = ParagraphBuilder.CreateStandardTextParagraph(document); //Create some simple Text para.TextContent.Add(new SimpleText(document, "Some simple text. And I have a footnode")); //Create a Footnote para.TextContent.Add(new Footnote(document, "Footer Text", "1", FootnoteType.footnode)); //Add the paragraph document.Content.Add(para); //Save document.SaveTo("example11_footnote.odt"); }
public void ParagraphFormatedText() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a standard paragraph using the ParagraphBuilder Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some formated text FormatedText formText = new FormatedText(document, "T1", "Some formated text!"); formText.TextStyle.TextProperties.Bold = "bold"; paragraph.TextContent.Add(formText); //Add the paragraph to the document document.Content.Add(paragraph); //Save empty document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"formated.odt"); }
void Example9() { TextDocument document = new TextDocument (); document.New (); //Find a Header template IStyle style = document.CommonStyles.GetStyleByName ("Heading_20_1"); //Assert.IsNotNull (style, "Style with name Heading_20_1 must exist"); //Assert.IsTrue (style is ParagraphStyle, "style must be a ParagraphStyle"); ((ParagraphStyle)style).TextProperties.FontName = FontFamilies.BroadwayBT; //Create a header that use the standard style Heading_20_1 Header header = new Header (document, Headings.Heading_20_1); //Add some text header.TextContent.Add (new SimpleText (document, "I am the header text and my style template was modified :)")); //Add header to the document document.Content.Add (header); //save the document document.SaveTo ("example9_modifiedCommonStyle.odt"); }
public void Add2GraphicsWithSameNameFromDifferentLocations() { string file1 = @"E:\fotos\schnee.jpg"; string file2 = @"E:\fotos\resize\schnee.jpg"; TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); Frame frame = new Frame(textdocument, "frame1", "graphic1", file1); p.Content.Add(frame); Paragraph p1 = ParagraphBuilder.CreateStandardTextParagraph(textdocument); Frame frame1 = new Frame(textdocument, "frame2", "graphic2", file2); p1.Content.Add(frame1); textdocument.Content.Add(p); textdocument.Content.Add(p1); textdocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+"graphic.odt"); }
public void CreateFreePositionGraphic() { TextDocument textdocument = new TextDocument(); textdocument.New(); Paragraph p = ParagraphBuilder.CreateStandardTextParagraph(textdocument); Frame frame = FrameBuilder.BuildStandardGraphicFrame(textdocument, "frame1", "graphic1", _imagefile); //Setps to set a graphic free with x and y frame.SvgX = "1.75cm"; frame.SvgY = "1.75cm"; ((FrameStyle)frame.Style).GraphicProperties.HorizontalPosition = "from-left"; ((FrameStyle)frame.Style).GraphicProperties.VerticalPosition = "from-top"; ((FrameStyle)frame.Style).GraphicProperties.HorizontalRelative = "paragraph"; ((FrameStyle)frame.Style).GraphicProperties.VerticalRelative = "paragraph"; p.Content.Add(frame); textdocument.Content.Add(p); textdocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+"grapic_free_xy.odt"); }
void Example13() { string headingText = "Some Heading with\n styles\t,line breaks, tab stops and extra whitspaces"; //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a new Heading Header header = new Header(document, Headings.Heading); //Create a TextCollection from headingText using the TextBuilder //You can conert every string incl. control character \n, \t, .. into //a ItextCollection using the TextBuilder ITextCollection textCol = TextBuilder.BuildTextCollection(document, headingText); //Add text collection header.TextContent = textCol; //Add header document.Content.Add(header); document.SaveTo("example13_HeadingWithControlCharacter.odt"); }
void Example12() { //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(document, "Some simple text "); //Create a XLink XLink xlink = new XLink(document, "http://www.OpenOffice.org", "OpenOffice.org"); //Add the textcontent para.TextContent.Add(stext); para.TextContent.Add(xlink); //Add paragraph to the document content document.Content.Add(para); //Save document.SaveTo("example12_XLink.odt"); }
void Example8() { TextDocument document = new TextDocument(); document.New(); Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); paragraph.TextContent.Add(new SimpleText(document, "Some text")); Paragraph paragraphClone = (Paragraph)paragraph.Clone(); ParagraphStyle paragraphStyle = new ParagraphStyle(document, "P1"); paragraphStyle.TextProperties.Bold = "bold"; //Add paragraph style to the document, //only automaticaly created styles will be added also automaticaly document.Styles.Add(paragraphStyle); paragraphClone.ParagraphStyle = paragraphStyle; //Clone the clone Paragraph paragraphClone2 = (Paragraph)paragraphClone.Clone(); document.Content.Add(paragraph); document.Content.Add(paragraphClone); document.Content.Add(paragraphClone2); document.SaveTo("example8_clonedParagraphs.odt"); }
public void SimpleDateFieldTest() { // Create a new text document TextDocument td = new TextDocument(); td.New(); // Create a new paragraph Paragraph p = new Paragraph(td); DateField df = new DateField(td); // Set fixed to false whch means that the current date is displayed df.Fixed = XmlBoolean.False; // add the date field to content p.Content.Add(df); td.Content.Add(p); // test import/export td.SaveTo(AARunMeFirstAndOnce.outPutFolder + "field_date.odt"); //td.Load(AARunMeFirstAndOnce.outPutFolder + "field_date.odt"); //td.Fields.RemoveAt(0); // this document should be empty now!!! //td.SaveTo(AARunMeFirstAndOnce.outPutFolder + "field_date2.odt"); }
void Example14() { //Create a new text document TextDocument document = new TextDocument(); document.New(); //Create a numbered list List li = new List(document, "L1", ListStyles.Bullet, "L1P1"); //Create a new list item ListItem lit = new ListItem(li); //Create a paragraph Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(document); //Add some text paragraph.TextContent.Add(new SimpleText(document, "First item")); //Add paragraph to the list item lit.Content.Add(paragraph); //Add the list item li.Content.Add(lit); //Add the list document.Content.Add(li); //Save document document.SaveTo("example14_list.odt"); }
public void TextToOpenDocumentText() { TextDocument document = new TextDocument(); document.Load(AARunMeFirstAndOnce.inPutFolder+"TextToOpenDocument.txt"); Assert.IsNotNull(document.Content, "Must contain objects."); document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"TextToOpenDocument.odt"); }
public void TextDocumentWithImgMapReload() { string file = AARunMeFirstAndOnce.inPutFolder+@"imgmap.odt"; FileInfo fInfo = new FileInfo(file); //Load the text document TextDocument document = new TextDocument(); document.Load(file); IContent iContent = document.Content[2]; Assert.IsNotNull(iContent, "Must exist!"); Assert.IsTrue(iContent is Paragraph, "iContent have to be a paragraph! But is :"+iContent.GetType().Name); Assert.IsTrue(((Paragraph)iContent).Content[0] is Frame, "Must be a frame! But is :"+((Paragraph)iContent).Content[0].GetType().Name); Frame frame = ((Paragraph)iContent).Content[0] as Frame; Assert.IsTrue(frame.Content[1] is ImageMap, "Must be a ImageMap! But is :"+frame.Content[1].GetType().Name); ImageMap imageMap = frame.Content[1] as ImageMap; Assert.IsTrue(imageMap.Content[0] is DrawAreaRectangle, "Must be a DrawAreaRectangle! But is :" +imageMap.Content[0].GetType().Name); //Save it back again document.SaveTo(AARunMeFirstAndOnce.outPutFolder+fInfo.Name+".rel.odt"); }
public void TableOfContentsTest() { //Create new Document TextDocument textDocument = new TextDocument(); textDocument.New(); //Create a new Table of contents TableOfContents tableOfContents = new TableOfContents( textDocument, "Table_Of_Contents", false, false, "Table of Contents"); //Add the toc textDocument.Content.Add(tableOfContents); //Create a new heading, there's no need of the chapter number string sHeading = "A first headline"; //The corresponding text entry, here you need to set the //chapter number string sTocEntry = "1. A first headline"; Header header = new Header( textDocument, Headings.Heading_20_1); header.OutLineLevel = "1"; header.TextContent.Add(new SimpleText(textDocument, sHeading)); //add the header to the content textDocument.Content.Add(header); //add the toc entry text as entry to the Table of contents tableOfContents.InsertEntry(sTocEntry, 1); //Add some text to this chapter Paragraph paragraph = ParagraphBuilder.CreateStandardTextParagraph(textDocument); paragraph.TextContent.Add(new SimpleText(textDocument, "I'm the text for the first chapter!")); textDocument.Content.Add(paragraph); //Add a sub header to the first chapter //Create a new heading, there's no need of the chapter number sHeading = "A first sub headline"; //The corresponding text entry, here you need to set the //chapter number sTocEntry = "1.1. A first sub headline"; header = new Header( textDocument, Headings.Heading_20_2); header.OutLineLevel = "2"; header.TextContent.Add(new SimpleText(textDocument, sHeading)); //add the header to the content textDocument.Content.Add(header); //add the toc entry text as entry to the Table of contents tableOfContents.InsertEntry(sTocEntry, 2); //Add some text to this sub chapter paragraph = ParagraphBuilder.CreateStandardTextParagraph(textDocument); paragraph.TextContent.Add(new SimpleText(textDocument, "I'm the text for the subchapter chapter!")); textDocument.Content.Add(paragraph); // ListStyle listStyle = new ListStyle(textDocument, "TOC_LIST"); // listStyle.AutomaticAddListLevelStyles(ListStyles.Number); // textDocument.Styles.Add(listStyle); //Save it textDocument.SaveTo(AARunMeFirstAndOnce.outPutFolder+"toc.odt"); }
public void HeadingFilledWithTextBuilder() { const string headingText = "Some Heading with\n styles\t and more"; //Create a new text document var document = new TextDocument(); document.New(); //Create a new Heading var header = new Header(document, Headings.Heading); //Create a TextCollection from headingText using the TextBuilder var textCol = TextBuilder.BuildTextCollection(document, headingText); //Add text collection header.TextContent = textCol; //Add header document.Content.Add(header); document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"HeadingWithControlCharacter.odt"); }