We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to get metadata from PDF?

I am using Aspose library “aspose-pdf-9.7.1-jdk14.jar” and I want to get the metadata out of a PDF document.
In order to get an overview of all metadata entries stored in the PDF I first want to get all metadata keys out of it. Using the javadoc I come to following code:

Document pdf = new Document(inputStream);
Metadata pdfMetadata = pdf.getMetadata();

The javadoc says that #getKeys will return a com.aspose.ms.System.Collections.ICollection object but what I really get is a “z11” object what I do not know how to deal with (no explanation in javadoc).
How do I get the whole metadata from a PDF?

Thanks in advance,

Hello Marc,

Thanks for using our API’s

Please download the latest version of Aspose.Pdf for Java 17.1.0 for improved and more features.

To get file-specific information about a PDF file, first get the DocumentInfo object using the Document class getInfo(). Once the DocumentInfo object is retrieved, you can get the values of the individual properties.

The following code snippet shows you how to get PDF file information.


// Open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(“Original.pdf”);
// Get document information
com.aspose.pdf.DocumentInfo docInfo = pdfDocument.getInfo();
// Show document information
System.out.printf(“Author:-” + docInfo.getAuthor());
System.out.printf("\n Creation Date:-" + docInfo.getCreationDate());
System.out.printf("\n Keywords:-" + docInfo.getKeywords());
System.out.printf("\n Modify Date:-" + docInfo.getModDate());
System.out.printf("\n Subject:-" + docInfo.getSubject());
System.out.printf("\n Title:-" + docInfo.getTitle());

If you further questions, please feel free to contact us.

Best Regards,


Along with this, I am also interested in checking other properties of the PDF, whatever we see in Security tab in Document properties in Adobe Reader, e.g. whether Printing is allowed or not, whether Document Assembly is allowed or not, whether Document is password protected or not, etc. Is it possible using Aspose PDF ?

Document_Properties_Security_Tab.png (8.7 KB)



You can get and set the privileges of PDF document with DocumentPrivilege class. Please refer to this help topic: Set Privileges on an Existing PDF File

Hi Imran,

I have to get the current privileges … not set it.

How can I do so ? That post doesn’t have any info on the same.



We are sorry for the inconvenience. In order to check printing privilege of a PDF document, please try the code as follows:

String dataDir = "c:\\temp\\";
// Instantiate PdfFileInfo Class object.
com.aspose.pdf.facades.PdfFileInfo info = new com.aspose.pdf.facades.PdfFileInfo();
// Load your encrypted PDF document.
info.bindPdf(dataDir + "Document.pdf");
// Get DocumentPrivilege
DocumentPrivilege documentPrivilege = info.getDocumentPrivilege();
// Determine AllowPrint
boolean printingAccess = documentPrivilege.isAllowPrint();

Thank you @imran.rafique