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 (InputStream inputStream = Files.newInputStream(new File("src/main/resources/pdfPropertiesInput.pdf").toPath())) {
// Initial setup, create credentials instance
Credentials credentials = new ServicePrincipalCredentials(
System.getenv("PDF_SERVICES_CLIENT_ID"),
System.getenv("PDF_SERVICES_CLIENT_SECRET"));
// Creates a PDF Services instance
PDFServices pdfServices = new PDFServices(credentials);
// Creates an asset(s) from source file(s) and upload
Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
// Create parameters for the job
PDFPropertiesParams pdfPropertiesParams = PDFPropertiesParams.pdfPropertiesParamsBuilder()
.includePageLevelProperties()
.build();
// Creates a new job instance
PDFPropertiesJob pdfPropertiesJob = new PDFPropertiesJob(asset)
.setParams(pdfPropertiesParams);
// Submit the job and gets the job result
String location = pdfServices.submit(pdfPropertiesJob);
PDFServicesResponse<PDFPropertiesResult> pdfServicesResponse = pdfServices.getJobResult(location, PDFPropertiesResult.class);
PDFProperties pdfProperties = pdfServicesResponse.getResult().getPdfProperties();
// Fetch the requisite properties of the specified PDF.
LOGGER.info("Size of the specified PDF file: {}", pdfProperties.getDocument().getFileSize());
LOGGER.info("Version of the specified PDF file: {}", pdfProperties.getDocument().getPDFVersion());
LOGGER.info("Page count of the specified PDF file: {}", pdfProperties.getDocument().getPageCount());
} 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.