Free Support Forum -

Encrypt Specific Custom Word Document Properties As Base64 & Export to PDF using Java

I would like to export only specific custom property from word to pdf while converting.

I have used options.CustomPropertiesExport but it either exports all properties or none.

Is there a way to export only specific ones?

Also, can it be added in Base64 encryption?


You can first remove unwanted custom document properties and then convert Word Document to PDF. Please check the following sample C# code of Aspose.Words for .NET API:

ArrayList propertiesToKeep = new ArrayList();
propertiesToKeep.Add("specific custom property 1");
propertiesToKeep.Add("specific custom property 2");
propertiesToKeep.Add("specific custom property 3");

Document doc = new Document("C:\\Temp\\input.docx");

foreach (DocumentProperty property in doc.CustomDocumentProperties)
    if (!propertiesToKeep.Contains(property.Name))

PdfSaveOptions options = new PdfSaveOptions();
options.CustomPropertiesExport = PdfCustomPropertiesExport.Standard;

doc.Save("C:\\temp\\word to.pdf", options);

Unfortunately, your question isn’t clear enough therefore we request you to please elaborate your inquiry further by providing complete details of your use-case. This will help us to understand your scenario, and we will be in a better position to address your concerns accordingly.

Thanks for the reply, I am assuming the same works for Java as well.

Regarding encryption, say the document had a property ‘Title’ and value = ‘Aspose Word to PDF’

Is there any Aspose feature in Java to add encrypted(Base64) data of the title value (In this case, ‘QXNwb3NlIFdvcmQgdG8gUERG’) to PDF while conversion?

Also, according to you, the only way to export a specific custom property is to delete from word before conversion right?

Any other method such as Export(‘Title’) if exists?


We have logged following two issues in issue tracking system:

WORDSNET-22204: Provide API to Export Specific Custom Document Properties to PDF
WORDSNET-22205: Provide API to Encrypt Custom Document Properties As Base64 before Exporting to PDF

We will further look into the details of these requirements and will keep you updated on the status of linked issues.


Please try the following Java code of Aspose.Words:

ArrayList propertiesToKeep = new ArrayList();
propertiesToKeep.add("specific custom property 1");
propertiesToKeep.add("specific custom property 2");
propertiesToKeep.add("specific custom property 3");

Document doc = new Document("C:\\Temp\\input.docx");

for (DocumentProperty property : doc.getCustomDocumentProperties())
    if (!propertiesToKeep.contains(property.getName()))

PdfSaveOptions options = new PdfSaveOptions();
options.setCustomPropertiesExport(PdfCustomPropertiesExport.STANDARD);"C:\\temp\\word to.pdf", options);


Regarding WORDSNET-22204 & WORDSNET-22205, we have completed the work on these issues and concluded to close these issues as “Won’t fix”. These are a way too specific features. You can use workaround code shared in earlier posts and edit custom properties the way you want in the Aspsoe.Words’ DOM (Document Object Model) before saving to PDF. Also, custom document properties could be edited in the Aspose.Words’ PDF output by third-party tools like Aspose.PDF for Java.