AODL.Document.TextDocuments.TextDocument.New C# (CSharp) Method

New() public method

Create a blank new document.
public New ( ) : TextDocument
return TextDocument
		public TextDocument New()
		{
			this._xmldoc					= new XmlDocument();
			this.Styles = new StyleCollection();
			this._xmldoc.LoadXml(TextDocumentHelper.GetBlankDocument());
			this.NamespaceManager			= TextDocumentHelper.NameSpace(this._xmldoc.NameTable);

			this.DocumentConfigurations2	= new DocumentConfiguration2();

			this.DocumentManifest			= new DocumentManifest();
			this.DocumentManifest.New();

			this.DocumentMetadata			= new DocumentMetadata(this);
			this.DocumentMetadata.New();

			this.DocumentPictures			= new DocumentPictureCollection();

			this.DocumentSetting			= new DocumentSetting();
			this.DocumentSetting.New();

			this.DocumentStyles				= new DocumentStyles();
			this.DocumentStyles.New(this);
			this.ReadCommonStyles();

			this.Forms = new ODFFormCollection();
			this._formCollection.Clearing += FormsCollection_Clear;
			this._formCollection.Removed += FormsCollection_Removed;

			this.Fields.Clear();
			this.Content.Clear();
			
			
			this.VariableDeclarations = new VariableDeclCollection();
			
			this.DocumentThumbnails			= new DocumentPictureCollection();

			MasterPageFactory.RenameMasterStyles(
				this.DocumentStyles.Styles,
				this.XmlDoc, this.NamespaceManager);
			// Read the moved and renamed styles
			LocalStyleProcessor lsp = new LocalStyleProcessor(this, false);
			lsp.ReReadKnownAutomaticStyles();
			new MasterPageFactory(m_dirInfo).FillFromXMLDocument(this);
			return this;
		}

Usage Example

		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);
		}
All Usage Examples Of AODL.Document.TextDocuments.TextDocument::New