Edit in GitHubLog an issue

Get PDF Properties

Use this service to get the metadata properties of a PDF. Metadata including page count, PDF version, file size, compliance levels, font info, permissions and more are provided in JSON format for easy processing.

This data can be used to: check if a document is fully text searchable (OCR), understand the e-signature certificate info, find out compliance levels (e.g., PDF/A and PDF/UA), assess file size before compressing, check permissions related to copy, edit, printing, encryption, and much more.

Rest API

See our public API Reference for PDF Properties.

Fetch PDF Properties

The sample below fetches the properties of an input PDF.

Please refer the API usage guide to understand how to use our APIs.

Copied to your clipboard
// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
// Run the sample:
// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfproperties.GetPDFProperties
public class GetPDFProperties {
// Initialize the logger.
private static final Logger LOGGER = LoggerFactory.getLogger(GetPDFProperties.class);
public static void main(String[] args) {
try {
// Initial setup, create credentials instance.
Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()
.withClientId("PDF_SERVICES_CLIENT_ID")
.withClientSecret("PDF_SERVICES_CLIENT_SECRET")
.build();
//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
PDFPropertiesOperation pdfPropertiesOperation = PDFPropertiesOperation.createNew();
// Provide an input FileRef for the operation
FileRef source = FileRef.createFromLocalFile("src/main/resources/pdfPropertiesInput.pdf");
pdfPropertiesOperation.setInputFile(source);
// Build PDF Properties options to include page level properties and set them into the operation
PDFPropertiesOptions pdfPropertiesOptions = PDFPropertiesOptions.PDFPropertiesOptionsBuilder()
.includePageLevelProperties(true)
.build();
pdfPropertiesOperation.setOptions(pdfPropertiesOptions);
// Execute the operation ang get properties of the PDF in PDFProperties object.
PDFProperties result = pdfPropertiesOperation.execute(executionContext);
// Get properties of the PDF
LOGGER.info("The Page level properties of the PDF: {}", result.getDocument().getPageCount());
LOGGER.info("The Fonts used in the PDF: ");
for(Font font: result.getDocument().getFonts()) {
LOGGER.info(font.getName());
}
} catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {
LOGGER.error("Exception encountered while executing operation", ex);
}
}
}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.