Represent a opendocument text document.
Inheritance: IDisposable, IDocument
Beispiel #1
0
		public void FrameWriteTest()
		{
			TextDocument textdocument = new TextDocument();
			textdocument.New();

			// Create a frame incl. graphic file
			Frame frame					= FrameBuilder.BuildStandardGraphicFrame(
				textdocument, "frame1", "graphic1", _imagefile);
			
			// Create some event listeners (using OpenOffice friendly syntax).
			EventListener script1 = new EventListener(textdocument,
			                                          "dom:mouseover", "javascript",
			                                          "vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share");
			EventListener script2 = new EventListener(textdocument,
			                                          "dom:mouseout", "javascript",
			                                          "vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share");
			EventListeners listeners = new EventListeners(textdocument, new EventListener[] { script1, script2 });
			
			// Create and add some area rectangles
			DrawAreaRectangle[] rects = new DrawAreaRectangle[2];
			rects[0] = new DrawAreaRectangle(textdocument, "4cm", "4cm", "2cm", "2cm");
			rects[0].Href = @"http://www.eduworks.com";
			rects[1] = new DrawAreaRectangle(textdocument, "1cm", "1cm", "2cm", "2cm", listeners);

			// Create and add an image map, referencing the area rectangles
			ImageMap map = new ImageMap(textdocument, rects);
			frame.Content.Add(map);

			// Add the frame to the text document
			textdocument.Content.Add(frame);

			// Save the document
			textdocument.SaveTo(_framefile3);
			textdocument.Dispose();
		}
Beispiel #2
0
		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");
		}
Beispiel #3
0
		public void PlaceholderTest()
		{
			// Create a new text document
			TextDocument td = new TextDocument();
			td.New();
            
			// Add paragraph 1 with a text placeholder in it
			Paragraph p1 = new Paragraph(td);
			p1.TextContent.Add(new SimpleText(td, "Insert text here: "));
			Placeholder plch1 = new Placeholder(td, PlaceholderType.Text, "A text placeholder");
			plch1.Value = "Text";
			p1.Content.Add(plch1);
			td.Content.Add(p1);

			// Add paragraph 2 with a text-box placeholder in it
			Paragraph p2 = new Paragraph(td);
			p2.TextContent.Add(new SimpleText(td, "Insert text-box here: "));
			Placeholder plch2 = new Placeholder(td, PlaceholderType.TextBox, "A text-box placeholder");
			plch2.Value = "Text-Box";
			p2.Content.Add(plch2);
			td.Content.Add(p2);

			// Add paragraph 3 with a table placeholder in it
			Paragraph p3 = new Paragraph(td);
			p3.TextContent.Add(new SimpleText(td, "Insert table here: "));
			Placeholder plch3 = new Placeholder(td, PlaceholderType.Table, "A table placeholder");
			plch3.Value = "Table";
			p3.Content.Add(plch3);
			td.Content.Add(p3);

			// Add paragraph 4 with an object placeholder in it
			Paragraph p4 = new Paragraph(td);
			p4.TextContent.Add(new SimpleText(td, "Insert object here: "));
			Placeholder plch4 = new Placeholder(td, PlaceholderType.Object, "An object placeholder");
			plch4.Value = "Object";
			p4.Content.Add(plch4);
			td.Content.Add(p4);

			// Add paragraph 5 with an image placeholder in it
			Paragraph p5 = new Paragraph(td);
			p5.TextContent.Add(new SimpleText(td, "Insert image here: "));
			Placeholder plch5 = new Placeholder(td, PlaceholderType.Image, "An image placeholder");
			plch5.Value = "Image";
			p5.Content.Add(plch5);
			td.Content.Add(p5);

			// test save/load
			td.SaveTo(AARunMeFirstAndOnce.outPutFolder + "placeholder.odt");

			// find a field in the fields collection and change its value
			td.Fields.FindFieldByValue("Image").Value = "There should be an image here";
			
			// test html export!
			td.SaveTo(AARunMeFirstAndOnce.outPutFolder + "placeholder.html");
			td.Load(AARunMeFirstAndOnce.outPutFolder + "placeholder.odt");

			// resave it
            td.SaveTo(AARunMeFirstAndOnce.outPutFolder + "placeholder2.odt");
			
		}
Beispiel #4
0
		public void MetaDataDisplay()
		{
			TextDocument document		= null;
			
			document				= new TextDocument();
			document.Load(AARunMeFirstAndOnce.inPutFolder+"ProgrammaticControlOfMenuAndToolbarItems.odt");

			Console.WriteLine(document.DocumentMetadata.InitialCreator);
			Console.WriteLine(document.DocumentMetadata.LastModified);
			Console.WriteLine(document.DocumentMetadata.CreationDate);
			Console.WriteLine(document.DocumentMetadata.CharacterCount);
			Console.WriteLine(document.DocumentMetadata.ImageCount);
			Console.WriteLine(document.DocumentMetadata.Keywords);
			Console.WriteLine(document.DocumentMetadata.Language);
			Console.WriteLine(document.DocumentMetadata.ObjectCount);
			Console.WriteLine(document.DocumentMetadata.PageCount);
			Console.WriteLine(document.DocumentMetadata.ParagraphCount);
			Console.WriteLine(document.DocumentMetadata.Subject);
			Console.WriteLine(document.DocumentMetadata.TableCount);
			Console.WriteLine(document.DocumentMetadata.Title);
			Console.WriteLine(document.DocumentMetadata.WordCount);

			document.DocumentMetadata.SetUserDefinedInfo(UserDefinedInfo.Info1, "Nothing");
			Console.WriteLine(document.DocumentMetadata.GetUserDefinedInfo(UserDefinedInfo.Info1));
		}
		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);
		}
Beispiel #6
0
 public void DrawTextBox()
 {
     //New TextDocument
     TextDocument textdocument = new TextDocument();
     textdocument.New();
     //Standard Paragraph
     Paragraph paragraphOuter = new Paragraph(textdocument, ParentStyles.Standard.ToString());
     //Create Frame for DrawTextBox
     Frame frameOuter = new Frame(textdocument, "frame1");
     //Create DrawTextBox
     DrawTextBox drawTextBox = new DrawTextBox(textdocument);
     //Create a paragraph for the drawing frame
     Paragraph paragraphInner = new Paragraph(textdocument, ParentStyles.Standard.ToString());
     //Create the frame with the Illustration resp. Graphic
     Frame frameIllustration = new Frame(textdocument, "frame2", "graphic1", _imagefile);
     //Add Illustration frame to the inner Paragraph
     paragraphInner.Content.Add(frameIllustration);
     //Add inner Paragraph to the DrawTextBox
     drawTextBox.Content.Add(paragraphInner);
     //Add the DrawTextBox to the outer Frame
     frameOuter.Content.Add(drawTextBox);
     //Add the outer Frame to the outer Paragraph
     paragraphOuter.Content.Add(frameOuter);
     //Add the outer Paragraph to the TextDocument
     textdocument.Content.Add(paragraphOuter);
     //Save the document
     textdocument.SaveTo(_framefile2);
 }
		public void ImportTest1 ()
		{
			string file = AARunMeFirstAndOnce.inPutFolder+"pagestyles.odt";
			TextDocument textDocument = new TextDocument();
			textDocument.Load(file);
			TextMasterPage txtMP = textDocument.TextMasterPageCollection.GetDefaultMasterPage();
			Assert.IsNotNull(txtMP, "The default text mast page style must exists.");
		}
 public void EmptyDocument()
 {
     //Create a new text document
     var document					= new TextDocument();
     document.New();
     //Save empty
     document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"empty.odt");
 }
Beispiel #9
0
		public void NestedFormTest()
		{
			//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");
			ODFForm child_form = new ODFForm(document, "childform");

			main_form.Method = Method.Get;
			main_form.Method = Method.Get;
			
			// Create a frame
			ODFFrame frm = new ODFFrame(main_form, p.Content, "frm", "5mm", "5mm", "5cm", "3cm");
			frm.Label = "Main form";
			// 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 = "This is a main form";
			// Add the button to the form control list
			main_form.Controls.Add (butt);

			// Add the forms to the main form!
			document.Forms.Add(main_form);
			// Add the paragraph to the content list
			document.Content.Add(p);

			
			// adding controls to the nested form
			ODFFrame frm_child = new ODFFrame(child_form, p.Content, "frm_child", "5mm", "35mm", "5cm", "3cm");
			frm_child.Label = "Child form";
			child_form.Controls.Add (frm_child);
			
			ODFButton butt_child = new ODFButton(child_form, p.Content, "butt_child", "1cm", "45mm", "4cm", "1cm");
			butt_child.Label = "This is a child form";
			child_form.Controls.Add (butt_child);
			main_form.ChildForms.Add(child_form);

			ODFButton b = document.FindControlById("butt_child") as ODFButton;
			Assert.IsNotNull(b, "Error! could not find the specified control");
			b.Label = "Child form:)";

			
			// Add the forms to the main form!
			document.Forms.Add(main_form);
            // Add the paragraph to the content list
			document.Content.Add(p);

			document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test.odt");
			document.Load(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test.odt");
			document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"nested_forms_test2.odt");
		}
		public void FooterContentsTest()
		{
			string file = AARunMeFirstAndOnce.inPutFolder+"pagestyles.odt";
			TextDocument textDocument = new TextDocument();
			textDocument.Load(file);
			TextMasterPage txtMP = textDocument.TextMasterPageCollection.GetDefaultMasterPage();
			Assert.IsNotNull(txtMP.TextPageFooter, "The page header must exist.");
			Assert.IsNotNull(txtMP.TextPageFooter.ContentCollection, "Content collection must exist.");
			Assert.IsTrue(txtMP.TextPageFooter.ContentCollection.Count > 0, "There must be content in the page footers content collection.");
		}
Beispiel #11
0
		public void GetStyleByName_Null()
		{
			TextDocument document = new TextDocument();
			document.New();
			StyleCollection collection = new StyleCollection();
			IStyle nullStyle = new TableStyle(document, string.Empty);
			collection.Add(nullStyle);
			
			Assert.AreEqual(nullStyle, collection.GetStyleByName(null));
		}
Beispiel #12
0
 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");
		}
Beispiel #14
0
		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 CloneTable()
		{
			TextDocument docuemnt = new TextDocument();
			docuemnt.New();
			Table table = new Table(docuemnt, "table name", "table style");
			
			int numberOfColumns = 10;
			int numberOfRows = 10;
			
			// prepare data
			// add columns
			for (int i = 0; i < numberOfColumns; i++)
			{
				table.ColumnCollection.Add(new Column(table, "style name " + i));
			}
			
			Row row = null;
			// Add rows
			for (int i = 0; i < 2; i++)
			{
				row = new Row(table);
				for (int i1 = 0; i1 < numberOfColumns; i1++)
				{
					Paragraph par = ParagraphBuilder.CreateStandardTextParagraph(docuemnt);
					par.TextContent.AddRange(TextBuilder.BuildTextCollection(docuemnt, (i * numberOfColumns).ToString() + i1));
					row.Cells.Add(new Cell(table.Document, "cell style " + i));
					//row.Cells.Add(new Cell(table.Document));
					row.Cells[i1].Content.Add(par);
					
				}
				table.Rows.Insert(0, row);
			}
			
			
			// clone many rows
			row = table.Rows[0];
			using (IPerformanceCounter counter = new PerformanceCounter())
			{
				for (int i = 0; i < numberOfRows; i++)
				{
					Row newRow = new Row(table, row.StyleName);
					foreach (Cell rowCell in row.Cells)
					{
						Cell cell = new ContentMocker().CloneAny(rowCell) as Cell;
						
						newRow.Cells.Add(cell);
					}
				}
				
				Console.WriteLine(string.Format(
					"Test executed in {0} seconds", counter.GetSeconds()));
			}
		}
Beispiel #16
0
		public void LoadDocument_With_PageBreak()
		{
			string file = AARunMeFirstAndOnce.inPutFolder + @"paragraph_with_page_break.odt";
			TextDocument textDocument = new TextDocument();
			textDocument.Load(file);

			Assert.AreEqual(3, textDocument.Content.Count);
			Paragraph paragraph = textDocument.Content[2] as Paragraph;
			Assert.IsNotNull(paragraph);
			Assert.AreEqual("page", paragraph.ParagraphStyle.ParagraphProperties.BreakBefore );
			
		}
		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");
		}
Beispiel #18
0
		public void LoadGraphichAndSearchForAlternateText()
		{
			TextDocument document = new TextDocument();
			document.Load(AARunMeFirstAndOnce.inPutFolder + "ImageDocument.odt");
			Assert.AreEqual(3, document.Content.Count);
			Assert.AreEqual(true, document.Content[2] is Paragraph);
			Paragraph par = document.Content[2] as Paragraph;
			Assert.AreEqual(true, par.Content[0] is Frame);
			Frame frame = par.Content[0] as Frame;
			
			Assert.AreEqual("<alternative AODL text>", frame.AlternateText);
		}
 public void NestedTable()
 {
     //Create a new text document
     var document = new TextDocument();
     document.New();
     //Create a table for a text document using the TableBuilder
     var table = TableBuilder.CreateTextDocumentTable(
         document,
         "table1",
         "table1",
         3,
         3,
         16.99,
         false,
         false);
     //Create a standard paragraph
     var paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
     //Add some simple text
     paragraph.TextContent.Add(new SimpleText(document, "Some cell text"));
     Assert.IsNotNull(table.RowCollection, "Must exist.");
     Assert.IsTrue(table.RowCollection.Count == 3, "There must be 3 rows.");
     //Insert paragraph into the second cell
     table.RowCollection[0].CellCollection[1].Content.Add(paragraph);
     //Get width of the nested table
     var nestedTableWidth = SizeConverter.GetDoubleFromAnOfficeSizeValue(
         table.ColumnCollection[0].ColumnStyle.ColumnProperties.Width);
     //Create another table using the TableBuilder
     var nestedTable = TableBuilder.CreateTextDocumentTable(
         document,
         "table1",
         "table1",
         2,
         2,
         nestedTableWidth,
         false,
         false);
     //Create a new standard paragraph
     paragraph = ParagraphBuilder.CreateStandardTextParagraph(document);
     //Add some simple text
     paragraph.TextContent.Add(new SimpleText(document, "Some cell text inside the nested table"));
     Assert.IsNotNull(nestedTable.RowCollection, "Must exist.");
     Assert.IsTrue(nestedTable.RowCollection.Count == 2, "There must be 3 rows.");
     //Insert paragraph into the first cell
     nestedTable.RowCollection[0].CellCollection[0].Content.Add(paragraph);
     //Insert the nested table into the first row and first cell
     table.RowCollection[0].CellCollection[0].Content.Add(nestedTable);
     Assert.IsTrue(table.RowCollection[0].CellCollection[0].Content[0] is Table, "Must be the nested table.");
     //Add table to the document
     document.Content.Add(table);
     //Save the document
     document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "nestedTable.odt");
 }
 public void BulletListTest()
 {
     //Create a new text document
     var document					= new TextDocument();
     document.New();
     //Create a bullet list
     var li = new AODL.Document.Content.Text.List(document, "L1", ListStyles.Bullet, "L1P1");
     Assert.IsNotNull(li.Node, "Node object must exist!");
     Assert.IsNotNull(li.Style, "Style object must exist!");
     Assert.IsNotNull(li.ListStyle.ListlevelStyles, "ListLevelStyleCollection must exist!");
     Assert.IsTrue(li.ListStyle.ListlevelStyles.Count == 10, "Must exist exactly 10 ListLevelStyle objects!");
     Assert.IsNotNull(li.ListStyle.ListlevelStyles[1].ListLevelProperties, "ListLevelProperties object must exist!");
 }
		public void NumberedListTest()
		{
			//Create a new text document
			TextDocument document					= new TextDocument();
			document.New();
			//Create a numbered list
			List li				= new List(document, "L1", ListStyles.Number, "L1P1");
			Assert.IsNotNull(li.Node, "Node object must exist!");
			Assert.IsNotNull(li.Style, "Style object must exist!");
			Assert.IsNotNull(li.ListStyle.ListlevelStyles, "ListLevelStyleCollection must exist!");
			Assert.IsTrue(li.ListStyle.ListlevelStyles.Count == 10, "Must exist exactly 10 ListLevelStyle objects!");
			Assert.IsNotNull(li.ListStyle.ListlevelStyles[1].ListLevelProperties, "ListLevelProperties object must exist!");
		}
Beispiel #22
0
		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 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");
		}
 public void FootnoteText()
 {
     //Create new TextDocument
     var document		= new TextDocument();
     document.New();
     //Create a new Paragph
     var 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(AARunMeFirstAndOnce.outPutFolder+"footnote.odt");
 }
        /// <summary>
        /// Exports the provided report template to an ODT document.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        protected override Stream Export(IGenerationContext context)
        {
            IReportTemplateSection sdet = context.Template.Sections.GetSection(SectionType.Detail);

            TextDocument doc = new TextDocument();
            doc.New();

            doc.DocumentConfigurations2 = null;

            doc.DocumentMetadata.Creator = context.Template.Description.Author;
            doc.DocumentMetadata.Title = context.Template.Description.Name;

            WriteElement(sdet.RootElement, context, doc);

            return CreateStream(doc);
        }
		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");
		}
Beispiel #27
0
 public void DisplyMetaData(TextDocument document)
 {
     Console.WriteLine(document.DocumentMetadata.InitialCreator);
     Console.WriteLine(document.DocumentMetadata.LastModified);
     Console.WriteLine(document.DocumentMetadata.CreationDate);
     Console.WriteLine(document.DocumentMetadata.CharacterCount);
     Console.WriteLine(document.DocumentMetadata.ImageCount);
     Console.WriteLine(document.DocumentMetadata.Keywords);
     Console.WriteLine(document.DocumentMetadata.Language);
     Console.WriteLine(document.DocumentMetadata.ObjectCount);
     Console.WriteLine(document.DocumentMetadata.PageCount);
     Console.WriteLine(document.DocumentMetadata.ParagraphCount);
     Console.WriteLine(document.DocumentMetadata.Subject);
     Console.WriteLine(document.DocumentMetadata.TableCount);
     Console.WriteLine(document.DocumentMetadata.Title);
     Console.WriteLine(document.DocumentMetadata.WordCount);
 }
Beispiel #28
0
		public void Add2GraphicsWithSameNameFromDifferentLocations()
		{
			string file1 = _imagefile; //@"E:\fotos\schnee.jpg";
			string file2 = _imagefile; //@"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 TextReportGenerator ()
        {
            iTextSharp.text.Document.Compress = false;
            document = new TextDocument();
            document.New();

            BOLD_STYLE = new TextStyle (document, "boldML");
            BOLD_STYLE.TextProperties.Bold = "bold";
            BOLD_STYLE.TextProperties.FontName = "Times-Roman";
            document.Styles.Add (BOLD_STYLE);

            BOLD_UNDERLINE_STYLE = new TextStyle (document, "boldUndelineML");
            BOLD_UNDERLINE_STYLE.TextProperties.Bold = "bold";
            BOLD_UNDERLINE_STYLE.TextProperties.FontName = "Times-Roman";
            BOLD_UNDERLINE_STYLE.TextProperties.Underline = "solid";
            document.Styles.Add (BOLD_UNDERLINE_STYLE);

        }
Beispiel #30
0
 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");
 }
Beispiel #31
0
        /// <summary>
        /// Creates the text document table.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="styleName">Name of the style.</param>
        /// <param name="rows">The rows.</param>
        /// <param name="columns">The columns.</param>
        /// <param name="width">The width.</param>
        /// <param name="useTableRowHeader">if set to <c>true</c> [use table row header].</param>
        /// <param name="useBorder">The useBorder.</param>
        /// <returns></returns>
        private Table CreateTextDocumentTable(
            AODL.Document.TextDocuments.TextDocument document,
            string tableName,
            string styleName,
            int rows,
            int columns,
            double width,
            Table originalTable)
        {
            string tableCnt = document.DocumentMetadata.TableCount.ToString();
            Table  table    = new Table(document, tableName, styleName);

            table.TableStyle.TableProperties.Width = width.ToString().Replace(",", ".") + "cm";

            for (int i = 0; i < columns; i++)
            {
                Column column = new Column(table, originalTable.ColumnCollection[i].StyleName);
                //column.ColumnStyle.ColumnProperties.Width = GetColumnCellWidth(columns, width);
                table.ColumnCollection.Add(column);
            }

            for (int ir = 0; ir < rows; ir++)
            {
                Row row = new Row(table, originalTable.Rows[ir].StyleName);

                for (int ic = 0; ic < columns; ic++)
                {
                    Cell cell = new Cell(table.Document, originalTable.Rows[ir].Cells[ic].StyleName);
                    //if (useBorder)
                    //	cell.CellStyle.CellProperties.Border = Border.NormalSolid;
                    row.Cells.Add(cell);
                }

                table.Rows.Add(row);
            }

            return(table);
        }