Free Support Forum - aspose.com

Which Word fields can be supported by saving to PDF from Aspose.Words

Hi Support,

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.

Thanks & regards.
Vincent

One more issue about CreateDate is wiered in PDF, please the picture:


Hi Vincent,

Thanks for your inquiry.

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;

Moreover, I would like to suggest you the following link for a description of supported fields:
http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/about-field-update.html

I hope, this will help.

Best Regards,

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,

Yes, the workaroun can be used. But it seems like a defect of Aspose.Words can not support NUMWORDS and CREATEDATE.

The fields listed in http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/about-field-update.html can be supported by Word, are they be supported for PDF also? Please clarification.

Thank you.

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,

Could you please explain why there is big difference between PDF and Word for the same field CREATEDATE? Please see the above picture.

Thank you.

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");

Hope this helps.

Best regards,