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.
Java
.NET
Node JS
REST API
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples2// Run the sample:3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfproperties.GetPDFProperties45 public class GetPDFProperties {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(GetPDFProperties.class);910 public static void main(String[] args) {1112 try (InputStream inputStream = Files.newInputStream(new File("src/main/resources/pdfPropertiesInput.pdf").toPath())) {13 // Initial setup, create credentials instance14 Credentials credentials = new ServicePrincipalCredentials(15 System.getenv("PDF_SERVICES_CLIENT_ID"),16 System.getenv("PDF_SERVICES_CLIENT_SECRET"));1718 // Creates a PDF Services instance19 PDFServices pdfServices = new PDFServices(credentials);2021 // Creates an asset(s) from source file(s) and upload22 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());2324 // Create parameters for the job25 PDFPropertiesParams pdfPropertiesParams = PDFPropertiesParams.pdfPropertiesParamsBuilder()26 .includePageLevelProperties()27 .build();2829 // Creates a new job instance30 PDFPropertiesJob pdfPropertiesJob = new PDFPropertiesJob(asset)31 .setParams(pdfPropertiesParams);3233 // Submit the job and gets the job result34 String location = pdfServices.submit(pdfPropertiesJob);35 PDFServicesResponse<PDFPropertiesResult> pdfServicesResponse = pdfServices.getJobResult(location, PDFPropertiesResult.class);3637 PDFProperties pdfProperties = pdfServicesResponse.getResult().getPdfProperties();3839 // 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 }
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd PDFPropertiesAsJSONObject/4// dotnet run GetPDFProperties.csproj56namespace GetPDFProperties7{8 class Program9 {10 private static readonly ILog log = LogManager.GetLogger(typeof(Program));11 static void Main()12 {13 //Configure the logging14 ConfigureLogging();15 try16 {17 // Initial setup, create credentials instance.18 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()19 .WithClientId("PDF_SERVICES_CLIENT_ID")20 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")21 .Build();2223 //Create an ExecutionContext using credentials and create a new operation instance.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);25 PDFPropertiesOperation pdfPropertiesOperation = PDFPropertiesOperation.CreateNew();2627 // Provide an input FileRef for the operation28 FileRef source = FileRef.CreateFromLocalFile(@"pdfPropertiesInput.pdf");29 pdfPropertiesOperation.SetInput(source);3031 // Build PDF Properties options to include page level properties and set them into the operation32 PDFPropertiesOptions pdfPropertiesOptions = PDFPropertiesOptions.PDFPropertiesOptionsBuilder()33 .IncludePageLevelProperties(true)34 .Build();35 pdfPropertiesOperation.SetOptions(pdfPropertiesOptions);3637 // Execute the operation ang get properties of the PDF in PDFProperties object.38 PDFProperties pdfProperties = pdfPropertiesOperation.Execute(executionContext);39 Console.WriteLine("The resultant PDF Properties are: " + result.ToString());4041 }42 catch (ServiceUsageException ex)43 {44 log.Error("Exception encountered while executing operation", ex);45 }46 // Catch more errors here. . .47 }4849 static void ConfigureLogging()50 {51 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());52 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));53 }54 }55}
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/pdfproperties/get-pdf-properties.js45const {6 ServicePrincipalCredentials,7 PDFServices,8 MimeType,9 PDFPropertiesParams,10 PDFPropertiesJob,11 PDFPropertiesResult,12 SDKError,13 ServiceUsageError,14 ServiceApiError15} = require("@adobe/pdfservices-node-sdk");16const fs = require("fs");1718(async () => {19 let readStream;20 try {21 // Initial setup, create credentials instance22 const credentials = new ServicePrincipalCredentials({23 clientId: process.env.PDF_SERVICES_CLIENT_ID,24 clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET25 });2627 // Creates a PDF Services instance28 const pdfServices = new PDFServices({credentials});2930 // Creates an asset(s) from source file(s) and upload31 readStream = fs.createReadStream("./pdfPropertiesInput.pdf");32 const inputAsset = await pdfServices.upload({33 readStream,34 mimeType: MimeType.PDF35 });3637 // Create parameters for the job38 const params = new PDFPropertiesParams({39 includePageLevelProperties: true40 });4142 // Creates a new job instance43 const job = new PDFPropertiesJob({inputAsset, params});4445 // Submit the job and get the job result46 const pollingURL = await pdfServices.submit({job});47 const pdfServicesResponse = await pdfServices.getJobResult({48 pollingURL,49 resultType: PDFPropertiesResult50 });5152 const pdfProperties = pdfServicesResponse.result.pdfProperties;5354 // Fetch the requisite properties of the specified PDF.55 console.log(`Size of the specified PDF file: ${pdfProperties.document.fileSize}`);56 console.log(`Version of the specified PDF file: ${pdfProperties.document.pdfVersion}`);57 console.log(`Page count of the specified PDF file: ${pdfProperties.document.pageCount}`);58 } catch (err) {59 if (err instanceof SDKError || err instanceof ServiceUsageError || err instanceof ServiceApiError) {60 console.log("Exception encountered while executing operation", err);61 } else {62 console.log("Exception encountered while executing operation", err);63 }64 } finally {65 readStream?.destroy();66 }67})();
Copied to your clipboard1// Please refer our REST API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/PDF-Properties34curl --location --request POST 'https://pdf-services.adobe.io/operation/pdfproperties' \5--header 'x-api-key: {{Placeholder for client_id}}' \6--header 'Content-Type: application/json' \7--header 'Authorization: Bearer {{Placeholder for token}}' \8--data-raw '{9 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",10 "pageLevel": false11}'