Hi,
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();
pdfMetadata.getKeys();
…
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,
Marc
Hello Marc,
The following code snippet shows you how to get PDF file information.
JAVA
// 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());
Hi,
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)
Thanks,
Rajiv
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.
Thanks,
Rajiv
We are sorry for the inconvenience. In order to check printing privilege of a PDF document, please try the code as follows:
Java
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();