I created a few Word fields in document, like CreateDate, NumWords and Page by Aspose.Words, and save it to Word and PDF documents. For Word document, all 3 fields can be updated and displayed correclty. But for PDF document, CreateDate and Page can work well, only NumWords did not occur.
Please confirm it is a defect. Or there are any documents which has a detailed fields lists PDF can not support.
Unfortunately, NUMWORDS field is not supported at the moment, but as a workaround, to insert the number of words in the document you can use the following code snippet:
Document doc = new Document(@"C:\test.doc");
int wordsCount = doc.BuiltInDocumentProperties.Words;
Hi Vincent,
Thanks for your request. Awais meant, that you can use { DOCPROPERTY Words } field instead of { NUMWORDS }. These fields have the identical behavior, but DOCPROPERTY is supported by Aspose.Words.
By the way, you can also use { DOCPROPERTY CreateTime } instead of { CreateDate }.
Best regards,
Hi
Thanks for your request. Aspose.Words supports fields listed on this page upon updating fields. If the field is not listed on this page, you can still insert it using Aspose.Words and it will work correctly in MS Word. But you will not able to update this fields, i.e. field will not show an actual value after updating fields using Aspose.Words.
Best regards,
Hi
Thanks for your request. The problem occurs because by default Aspose.Words does not set CreateDate if you create a document from scratch. You can set it yourself using code like the following:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
doc.BuiltInDocumentProperties.CreatedTime = DateTime.Now;
builder.InsertField("CREATEDATE");
doc.UpdateFields();
doc.Save(@"Test001\out.doc");
doc.Save(@"Test001\out.pdf");