As someone who works with PDFs, it is not straightforward to view PDF metadata since it is not directly supported by Java. This tutorial shows you how to check and extract metadata from a PDF file in simple steps using the JPedal Java PDF library.
What is PDF Metadata
PDF Metadata is data about data, so it contains information about the PDF. This may include author, creation date, length and additional details. It is embedded within the PDF document and describes its various attributes. This metadata is often used for the purpose of organising, searching and managing PDF files.
Early versions of PDF contained an information ‘Dictionary’ however, in 2001 Adobe introduced the Extensible Metadata Platform (XMP) which allowed for more complex and standardized metadata. The current version of PDF Standard ISO 32000-2 (2007) further polishes accessibility and security features.
Why is PDF metadata important
Metadata allows documents to be used across different systems and platforms. It also gives the user a thorough understanding of the legal aspects of the document for compliance and auditing purposes. PDF metadata also allows you to find the PDF version you are using.
Other than that it has a important details about encryptions and permissions, helping secure sensitive information. Likewise, tags and structural information can help improve accessibility of documents for disabled people. With Java, you can extract PDF metadata using a few lines of code.
How to read PDF Metadata
There are tools online like PDFescape and Smallpdf which help you read PDF. However if you want to view your metadata programmatically, you can find solutions which are language-specific.
When it comes to Java for example, JPedal can help you view your PDF metadata and provide many additional features which let you have more control over your PDF.
How to find a PDF file page count
- Add JPedal to your class or module path. (download the trial jar).
- Create a File handle, InputStream or URL pointing to the PDF file
- Include a password if file password protected
- Open the PDF file
- Read the page count
- Close the PDF file
and the Java code to get a page count…
You can try print out the result to see if it’s working:
How to access a PDF file page size and rotation
- Add JPedal to your class or module path. (download the trial jar).
- Create a File handle, InputStream or URL pointing to the PDF file
- Include a password if file password protected
- Open the PDF file
- Read the page size and rotation
- Close the PDF file
and the Java code to read PDF page size and rotation…
You can try print out the result to see if it’s working: (getPageDimensions returns a float[] with 5 values:- x,y,w,h, pageRotation)
How to access PDF Document properties
- Add JPedal to your class or module path. (download the trial jar).
- Create a File handle, InputStream or URL pointing to the PDF file
- Include a password if file password protected
- Open the PDF file
- Access the properties
- Close the PDF file
and the Java code to read PDF Document properties…
You can try print out the result to see if it’s working:
How to detect if embedded fonts used in PDF
- Add JPedal to your class or module path. (download the trial jar).
- Create a File handle, InputStream or URL pointing to the PDF file
- Include a password if file password protected
- Open the PDF file
- Query the PDF file status
- Close the PDF file
and the Java code to detect embedded fonts…
Again, you can try print out the result to see if it’s working:
In this article I showed you how you can view pdf metadata using Java.
The JPedal PDF library allows you to solve these problems in Java
What is JPedal?
JPedal is a commercial Java PDF Library that makes it easy for Java developers to work with PDF Documents in Java.
Why use JPedal?
JPedal makes it much easier to work with PDF files from Java. Because we have been actively developing our Java PDF Toolkit for over 20 years, it works with all those problem PDF files out there.
What licenses are available?
We have 2 licenses available:
'Server' for on premises and cloud servers and 'OEM' for use in a named end user applications. Both are one time fees with options support renewal after 12 months.
How to use JPedal?
Want to learn more about JPedal and how to use it, we have plenty of tutorials and guides to help you.