We have a need to build sections of Word document based on certain conditions.
Does Aspose Word or anything in Aspose Total suite be used to allow us to do this ?
Thank you.
We have a need to build sections of Word document based on certain conditions.
Does Aspose Word or anything in Aspose Total suite be used to allow us to do this ?
Thank you.
Thanks for your inquiry. Yes, you can dynamically build Word document using Aspose.Words. Aspose.Words for .NET is a class library that enables your applications to perform a great range of document processing tasks. Aspose.Words supports DOC, DOCX, RTF, HTML, OpenDocument, PDF, XPS, EPUB and other formats. With Aspose.Words you can generate, modify, convert, render and print documents without utilizing Microsoft Word®.
Please refer to the following documentation link.
Programming with Documents
Hi … Thank you for responding.
Please let me explain our needs.
We are using a docx template that has content controls that we are using to bind to XML data to produce a populated docx word document that we, in turn, convert to PDF.
The problem we have is … we can have over 1000 different versions and so we are trying to approach this from the design point of dividing up sections of the word document into library that we can use to customize… put together in code.
Then once the docx is stitched together, we can use it to bind to our XML data and do the PDF conversion.
And if Aspose would allow us to do this… if you can point to some sample codes that would allow us to do this.
BTW…
We just got the Site Small Business License … so we are a paid customer. (DocsDirect.com
)
Thank you.
Thanks for your inquiry. Yes, you can bind content control to custom XML parts and save the document to PDF. StructuredDocumentTag.XmlMapping property gets an object that represents the mapping of this structured document tag to XML data in a custom XML part of the current document. Please read the members of XmlMapping class.
Please refer to the following article.
Binding Content Control to Custom XML Parts
If you still face problem, please share your input and output Word documents along with XML that you want to map with content control. We will then provide you more information about your query.
We dont have an issue binding data to the xml. We are already doing that.
I need some guidances and code samples on how to build Word docx file in sections.
So we can possibly store them in libraries and reconstitute each of them in code during composition.
I need to understand how your classes work to build sections and paragraphs so I can best design data model and tables to store them on database.
I explained my needs in earlier post.
Thanks for your inquiry. We suggest you please read about Aspose.Words document object model from here:
Aspose.Words Document Object Model
Tahir
Can you point me to a link that shows sample code on how to use Aspose word to create a Docx document from scratch … putting section/body/paragraph together.
The only code I found aren’t too clear. A lot of properties are read only and cannot be set.
example … when I was trying to assign a range.text to a string… I could not, since its read only.
If there is a way to set a text of a paragraph in code… can you point me to an example ?
Thanks
I also did not find a sample code on how to use Aspose.Words to create a document.
The ones I found are usually instantiate a Aspose document by passing a path to an already existing docx …
I need a sample of how to use Aspose.Words to create a docx from scratch.
Thanks
Thanks for your inquiry. We suggest you please read the following articles.
Creating a New Document
Working with Sections
Following code example shows how to create document from scratch. Hope this helps you.
// Create an "empty" document. Note that like in Microsoft Word,
// the empty document has one section, body and one paragraph in it.
Document doc = new Document();
// This truly makes the document empty. No sections (not possible in Microsoft Word).
doc.RemoveAllChildren();
// Create a new section node.
// Note that the section has not yet been added to the document,
// but we have to specify the parent document.
Section section = new Section(doc);
// Append the section to the document.
doc.AppendChild(section);
// Lets set some properties for the section.
section.PageSetup.SectionStart = SectionStart.NewPage;
section.PageSetup.PaperSize = Aspose.Words.PaperSize.Letter;
// The section that we created is empty, lets populate it. The section needs at least the Body node.
Body body = new Body(doc);
section.AppendChild(body);
// The body needs to have at least one paragraph.
// Note that the paragraph has not yet been added to the document,
// but we have to specify the parent document.
// The parent document is needed so the paragraph can correctly work
// with styles and other document-wide information.
Paragraph para = new Paragraph(doc);
body.AppendChild(para);
// We can set some formatting for the paragraph
para.ParagraphFormat.StyleName = "Heading 1";
para.ParagraphFormat.Alignment = ParagraphAlignment.Center;
// So far we have one empty paragraph in the document.
// The document is valid and can be saved, but lets add some text before saving.
// Create a new run of text and add it to our paragraph.
Run run = new Run(doc);
run.Text = "Hello World!";
run.Font.Color = System.Drawing.Color.Red;
para.AppendChild(run);
// Save the document.
doc.Save(MyDir + "Section.CreateFromScratch Out.doc");
Very helpful. Thank you.
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.
Can Aspose Word save the document down as HTML ?
If so, can you provide some sample code ?
Thank you.
Thanks for your inquiry. Please use the following code example to convert DOCX to HTML.
Document doc = new Document(MyDir + "input.docx");
doc.Save(MyDir + "output.html");
We suggest you please read the following article.
Saving a Document