Custom Properties Using Aspose.Words

Hi,
We are using Custom Properties API of aspose words to add a specific custom property to the word document before sending the document to the user.
We also have a scenario where we need to send the document as PDF instead of Word Document. We know that we can acheive this by specifying the format as PDF in the Document.Save() method of Aspose Words.
What we wanted to know is can we use the Custom Properties API of aspose words when we are saving the document as PDF instead of Word document?
Thanks,
Hari

Hi Hari,

Thanks for your inquiry. To export custom properties you should set ExportCustomPropertiesAsMetadata option; please see the following code snippet:

Document doc = new Document(@"C:\Temp\test.doc");
doc.CustomDocumentProperties.Add("prop1", true);
doc.CustomDocumentProperties.Add("prop2", 10);
PdfSaveOptions options = new PdfSaveOptions();
options.ExportCustomPropertiesAsMetadata = true;
doc.Save(@"C:\Temp\out.pdf", options);

I hope, this helps.

Best regards,

Hi,
The above code snippet works fine for me. Thanks for assisting.
But I having issue while I try to load the PDF again and the check the customproperties we added above. Please find the my code snippet failed for me.

Document doc = new Document(@"C:\Temp\out.pdf");
bool hasProperty = doc.CustomDocumentProperties.Contains("prop2");

I am receiving {“Unknown file format.”} error message.
Can you please assist how to load the PDF and check for the custom property?

Hi Hari,

Thanks for your inquiry.

No, you can’t load a PDF document into Aspose.Words’ DOM (document object modal). You can find a list of file formats that can be loaded with Aspose.Words below:
https://reference.aspose.com/words/net/aspose.words/loadformat

To process PDF documents, please use Aspose.Pdf component:
https://releases.aspose.com/pdf/net

Best regards,