Using evaluation dll


#1

Hello;
I just downloaded the Aspose.Word evaluation dll and from the published API I am thinking that this may be exactly what I have been looking for. My problem/question is this:

Using the following code sequence,

Word aspWord = new Word();
Aspose.Word.Document aspDoc = aspWord.Open(@“C:\PnlTestTemplate.doc”);
Aspose.Word.DocumentBuilder aspDocBldr = new DocumentBuilder(aspDoc);
aspDoc.Sections.Clear();
aspDocBldr.Font.Size = 10.0;
aspDocBldr.Font.Bold = true;
aspDocBldr.Font.Name = “Times New Roman”;
aspDocBldr.Writeln(“Header1”);
aspDocBldr.Writeln(“xxxxxxxxxxxxxxxxxxxxxxx”);
aspDocBldr.InsertParagraph();
aspDoc.Save(@“C:\MyTestInvoice.doc”,SaveFormat.FormatDocument);

all I get is a “C:\MyTestInvoice.doc” containing your evaluation banner “Evaluation Only. Created with Aspose.Word. Copyright 2003-2004 Aspose Pty Ltd.” – and nothing else.

Am I missing some required additional statements or is this how the evaluation DLL is intended to behave? Obviously, if this is the intended behavior, making an evaluation of the software is not possible so I am assuming (hoping) that I have omitted something from my code.

Thanks in advance.
JimL


#2

Try clearing the document before creating DocumentBuilder. Alternatively, if you want to start from a blank document, create a blank document in MS Word and open it.


#3

Thanks for the speedy reply.
However, moving the “Sections.Clear” before the “DocBuilder” throws an exception stating “The document needs to have at least one section.”.

Yes, I would like to start with an empty document, but only because there doesn’t appear to be a method to programmatically create a new document.

After playing with this a bit, I think the “Sections.Clear” is the culprit. Removing it allows the code to work properly. Starting with an empty document and using “Sections.Clear” causes it to again create a completely empty document.

Thanks
Jim


#4

You can use Document.Range.Delete rathern Sections.Clear. It should work without problems before creating DocumentBuilder.