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
1// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
2// Run the sample:
3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfproperties.GetPDFProperties
4
5 public class GetPDFProperties {
6
7 // Initialize the logger.
8 private static final Logger LOGGER = LoggerFactory.getLogger(GetPDFProperties.class);
9
10 public static void main(String[] args) {
11
12 try (InputStream inputStream = Files.newInputStream(new File("src/main/resources/pdfPropertiesInput.pdf").toPath())) {
13 // Initial setup, create credentials instance
14 Credentials credentials = new ServicePrincipalCredentials(
15 System.getenv("PDF_SERVICES_CLIENT_ID"),
16 System.getenv("PDF_SERVICES_CLIENT_SECRET"));
17
18 // Creates a PDF Services instance
19 PDFServices pdfServices = new PDFServices(credentials);
20
21 // Creates an asset(s) from source file(s) and upload
22 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
23
24 // Create parameters for the job
25 PDFPropertiesParams pdfPropertiesParams = PDFPropertiesParams.pdfPropertiesParamsBuilder()
26 .includePageLevelProperties()
27 .build();
28
29 // Creates a new job instance
30 PDFPropertiesJob pdfPropertiesJob = new PDFPropertiesJob(asset)
31 .setParams(pdfPropertiesParams);
32
33 // Submit the job and gets the job result
34 String location = pdfServices.submit(pdfPropertiesJob);
35 PDFServicesResponse<PDFPropertiesResult> pdfServicesResponse = pdfServices.getJobResult(location, PDFPropertiesResult.class);
36
37 PDFProperties pdfProperties = pdfServicesResponse.getResult().getPdfProperties();
38
39 // Fetch the requisite properties of the specified PDF.
40 LOGGER.info("Size of the specified PDF file: {}", pdfProperties.getDocument().getFileSize());
41 LOGGER.info("Version of the specified PDF file: {}", pdfProperties.getDocument().getPDFVersion());
42 LOGGER.info("Page count of the specified PDF file: {}", pdfProperties.getDocument().getPageCount());
43 } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
44 LOGGER.error("Exception encountered while executing operation", ex);
45 }
46 }
47 }
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.