Why PDF Services API?
Create, secure, and convert PDF documents
Create a PDF from Microsoft Office documents, protect the content, and convert to other formats.
Modify PDFs and optimize output
Programmatically alter a document, such as reordering, inserting, and rotating pages, as well as compressing the file.
Leverage Adobe's cloud-based services
Access the same cloud-based APIs that power Adobe's end user applications to quickly deliver scalable, secure solutions.
Key features of Adobe PDF Services API
PDF content extraction
Extract text, images, tables, and more from native and scanned PDFs into a structured JSON file. PDF Extract API leverages AI technology to accurately identify text objects and understand the natural reading order of different elements such as headings, lists, and paragraphs spanning multiple columns or pages. Extract font styles with identification of metadata such as bold and italic text and their position within your PDF. Extracted content is output in a structured JSON file format with tables in CSV or XLSX and images saved as PNG.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Extract-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/extractpdf' \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 "elementsToExtract": [11 "text"12 ]13}'1415// Legacy API can be found here16// https://documentcloud.adobe.com/document-services/index.html#post-extractPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/extractpdf/extract-text-info-from-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');6try {7 // Initial setup, create credentials instance.8 const credentials = PDFServicesSdk.Credentials9 .servicePrincipalCredentialsBuilder()10 .withClientId("PDF_SERVICES_CLIENT_ID")11 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")12 .build();1314 // Create an ExecutionContext using credentials15 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1617 // Build extractPDF options18 const options = new PDFServicesSdk.ExtractPDF.options.ExtractPdfOptions.Builder()19 .addElementsToExtract(PDFServicesSdk.ExtractPDF.options.ExtractElementType.TEXT).build();2021 // Create a new operation instance.22 const extractPDFOperation = PDFServicesSdk.ExtractPDF.Operation.createNew(),23 input = PDFServicesSdk.FileRef.createFromLocalFile(24 'resources/extractPDFInput.pdf',25 PDFServicesSdk.ExtractPDF.SupportedSourceFormat.pdf26 );2728 // Set operation input from a source file.29 extractPDFOperation.setInput(input);3031 // Set options32 extractPDFOperation.setOptions(options);3334 extractPDFOperation.execute(executionContext)35 .then(result => result.saveAsFile('output/ExtractTextInfoFromPDF.zip'))36 .catch(err => {37 if(err instanceof PDFServicesSdk.Error.ServiceApiError38 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {39 console.log('Exception encountered while executing operation', err);40 } else {41 console.log('Exception encountered while executing operation', err);42 }43 });44} catch (err) {45 console.log('Exception encountered while executing operation', err);46}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ExtractTextInfoFromPDF/4// dotnet run ExtractTextInfoFromPDF.csproj56namespace ExtractTextInfoFromPDF7{8 class Program9 {10 private static readonly ILog log = LogManager.GetLogger(typeof(Program));11 static void Main()12 {13 // Configure the logging.14 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 ExtractPDFOperation extractPdfOperation = ExtractPDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"extractPDFInput.pdf");29 extractPdfOperation.SetInputFile(sourceFileRef);3031 // Build ExtractPDF options and set them into the operation.32 ExtractPDFOptions extractPdfOptions = ExtractPDFOptions.ExtractPDFOptionsBuilder()33 .AddElementsToExtract(new List<ExtractElementType>(new []{ ExtractElementType.TEXT}))34 .Build();35 extractPdfOperation .SetOptions(extractPdfOptions);3637 // Execute the operation.38 FileRef result = extractPdfOperation.Execute(executionContext);3940 // Save the result to the specified location.41 result.SaveAs(Directory.GetCurrentDirectory() + "/output/ExtractTextInfoFromPDF.zip");42 }43 catch (ServiceUsageException ex)44 {45 log.Error("Exception encountered while executing operation", ex);46 }47 catch (ServiceApiException ex)48 {49 log.Error("Exception encountered while executing operation", ex);50 }51 catch (SDKException ex)52 {53 log.Error("Exception encountered while executing operation", ex);54 }55 catch (IOException ex)56 {57 log.Error("Exception encountered while executing operation", ex);58 }59 catch (Exception ex)60 {61 log.Error("Exception encountered while executing operation", ex);62 }63 }6465 static void ConfigureLogging()66 {67 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());68 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));69 }70 }71}
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.extractpdf.ExtractTextInfoFromPDF45public class ExtractTextInfoFromPDF {67 private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ExtractTextInfoFromPDF.class);89 public static void main(String[] args) {1011 try {1213 // Initial setup, create credentials instance.14 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()15 .withClientId("PDF_SERVICES_CLIENT_ID")16 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")17 .build();1819 // Create an ExecutionContext using credentials.20 ExecutionContext executionContext = ExecutionContext.create(credentials);2122 ExtractPDFOperation extractPDFOperation = ExtractPDFOperation.createNew();2324 // Provide an input FileRef for the operation25 FileRef source = FileRef.createFromLocalFile("src/main/resources/extractPdfInput.pdf");26 extractPDFOperation.setInputFile(source);2728 // Build ExtractPDF options and set them into the operation29 ExtractPDFOptions extractPDFOptions = ExtractPDFOptions.extractPdfOptionsBuilder()30 .addElementsToExtract(Arrays.asList(ExtractElementType.TEXT))31 .build();32 extractPDFOperation.setOptions(extractPDFOptions);3334 // Execute the operation35 FileRef result = extractPDFOperation.execute(executionContext);3637 // Save the result at the specified location38 result.saveAs("output/ExtractTextInfoFromPDF.zip");3940 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException e) {41 LOGGER.error("Exception encountered while executing operation", e);42 }43 }44}
Copied to your clipboard1# Get the samples from http://www.adobe.com/go/pdftoolsapi_python_sample2# Run the sample:3# python src/extractpdf/extract_txt_from_pdf.py45logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))67try:8 #get base path.9 base_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))1011 #Initial setup, create credentials instance.12 credentials = Credentials.service_principal_credentials_builder()13 .with_client_id('PDF_SERVICES_CLIENT_ID')14 .with_client_secret('PDF_SERVICES_CLIENT_SECRET')15 .build()1617 #Create an ExecutionContext using credentials and create a new operation instance.18 execution_context = ExecutionContext.create(credentials)19 extract_pdf_operation = ExtractPDFOperation.create_new()2021 #Set operation input from a source file.22 source = FileRef.create_from_local_file(base_path + "/resources/extractPdfInput.pdf")23 extract_pdf_operation.set_input(source)2425 #Build ExtractPDF options and set them into the operation26 extract_pdf_options: ExtractPDFOptions = ExtractPDFOptions.builder() \27 .with_element_to_extract(ExtractElementType.TEXT) \28 .build()29 extract_pdf_operation.set_options(extract_pdf_options)3031 #Execute the operation.32 result: FileRef = extract_pdf_operation.execute(execution_context)3334 #Save the result to the specified location.35 result.save_as(base_path + "/output/ExtractTextInfoFromPDF.zip")36except (ServiceApiException, ServiceUsageException, SdkException):37 logging.exception("Exception encountered while executing operation")
Adobe PDF Accessibility Auto-Tag API
Tag PDFs to improve accessibility. Identify the content structure and reading order, and tag tables, paragraphs, lists, headings, figures, and more to improve the reading experience of native or scanned PDFs with assistive technologies. Generate a tailored tagging report about added tags and any content that needs additional review.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our REST API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/PDF-Accessibility-Auto-Tag34curl --location --request POST 'https://pdf-services.adobe.io/operation/autotag' \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}'
Copied to your clipboard1// Get the samples from https://github.com/adobe/pdfservices-node-sdk-samples2// Run the sample:3// node src/autotagpdf/autotag-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 autotagPDF = PDFServicesSdk.AutotagPDF,18 autotagPDFOperation = autotagPDF.Operation.createNew();1920 // Set operation input from a source file.21 const input = PDFServicesSdk.FileRef.createFromLocalFile('autotagPDFInput.pdf');22 autotagPDFOperation.setInput(input);2324 // Execute the operation and Save the result to the specified location.25 autotagPDFOperation.execute(executionContext)26 .then(result => {27 result.taggedPDF.saveAsFile('autotagPDFOutput.pdf');28 })29 .catch(err => {30 if(err instanceof PDFServicesSdk.Error.ServiceApiError31 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {32 console.log('Exception encountered while executing operation', err);33 } else {34 console.log('Exception encountered while executing operation', err);35 }36 });3738} catch (err) {39 console.log('Exception encountered while executing operation', err);40}
Copied to your clipboard1// Get the samples from https://github.com/adobe/PDFServices.NET.SDK.Samples2// Run the sample:3// cd AutotagPDF/4// dotnet run AutotagPDF.csproj56namespace AutotagPDF7{8 class Program9 {10 private static readonly ILog log = LogManager.GetLogger(typeof(Program));1112 static void Main()13 {14 //Configure the logging15 ConfigureLogging();16 try17 {18 // Initial setup, create credentials instance.19 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()20 .WithClientId("PDF_SERVICES_CLIENT_ID")21 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")22 .Build();2324 //Create an ExecutionContext using credentials and create a new operation instance.25 ExecutionContext executionContext = ExecutionContext.Create(credentials);26 AutotagPDFOperation autotagPDFOperation = AutotagPDFOperation.CreateNew();2728 // Provide an input FileRef for the operation29 autotagPDFOperation.SetInput(FileRef.CreateFromLocalFile(@"autotagPDFInput.pdf"));3031 // Execute the operation32 AutotagPDFOutput autotagPDFOutput = autotagPDFOperation.Execute(executionContext);3334 // Save the output files at the specified location35 autotagPDFOutput.GetTaggedPDF().SaveAs(Directory.GetCurrentDirectory() + "autotagPDFOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 catch (ServiceApiException ex)42 {43 log.Error("Exception encountered while executing operation", ex);44 }45 catch (SDKException ex)46 {47 log.Error("Exception encountered while executing operation", ex);48 }49 catch (IOException ex)50 {51 log.Error("Exception encountered while executing operation", ex);52 }53 catch (Exception ex)54 {55 log.Error("Exception encountered while executing operation", ex);56 }57 }5859 static void ConfigureLogging()60 {61 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());62 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));63 }64 }65}
Copied to your clipboard1// Get the samples from https://github.com/adobe/pdfservices-java-sdk-samples2// Run the sample:3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.autotagpdf.AutotagPDF45public class AutotagPDF {6 // Initialize the logger.7 private static final Logger LOGGER = LoggerFactory.getLogger(AutotagPDF.class);89 public static void main(String[] args) {1011 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 AutotagPDFOperation autotagPDFOperation = AutotagPDFOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("autotagPDFInput.pdf");24 autotagPDFOperation.setInput(source);2526 // Execute the operation27 AutotagPDFOutput autotagPDFOutput = autotagPDFOperation.execute(executionContext);2829 // Save the tagged PDF output at the specified location30 autotagPDFOutput.getTaggedPDF().saveAs("autotagPDFOutput.pdf");3132 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {33 LOGGER.error("Exception encountered while executing operation", ex);34 }35 }36
Copied to your clipboard1# Get the samples from https://github.com/adobe/pdfservices-python-sdk-samples2# Run the sample:3# python src/autotagpdf/autotag_pdf.py45logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO'))67try:8 # get base path.9 base_path = str(Path(__file__).parents[2])1011 # Initial setup, create credentials instance.12 credentials = Credentials.service_principal_credentials_builder()13 .with_client_id('PDF_SERVICES_CLIENT_ID')14 .with_client_secret('PDF_SERVICES_CLIENT_SECRET')15 .build()1617 # Create an ExecutionContext using credentials and create a new operation instance.18 execution_context = ExecutionContext.create(credentials)19 autotag_pdf_operation = AutotagPDFOperation.create_new()2021 # Set operation input from a source file.22 input_file_path = 'autotagPdfInput.pdf'23 source = FileRef.create_from_local_file(base_path + '/resources/' + input_file_path)24 autotag_pdf_operation.set_input(source)2526 # Execute the operation.27 autotag_pdf_output: AutotagPDFOutput = autotag_pdf_operation.execute(execution_context)2829 input_file_name = Path(input_file_path).stem30 base_output_path = base_path + '/output/AutotagPDF/'3132 Path(base_output_path).mkdir(parents=True, exist_ok=True)33 tagged_pdf_path = f'{base_output_path}{input_file_name}-tagged.pdf'3435 # Save the result to the specified location.36 autotag_pdf_output.get_tagged_pdf().save_as(tagged_pdf_path)3738except (ServiceApiException, ServiceUsageException, SdkException) as e:39 logging.exception(f'Exception encountered while executing operation: {e}')
Create a PDF file
Create PDFs from a variety of formats, including static and dynamic HTML; Microsoft Word, PowerPoint, and Excel; as well as text, image, Zip, and URL. Support for HTML to PDF, DOC to PDF, DOCX to PDF, PPT to PDF, PPTX to PDF, XLS to PDF, XLSX to PDF, TXT to PDF, RTF to PDF, BMP to PDF, JPEG to PDF, GIF to PDF, TIFF to PDF, PNG to PDF
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Create-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/createpdf' \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}'1112// Legacy API can be found here13// https://documentcloud.adobe.com/document-services/index.html#post-createPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/createpdf/create-pdf-from-docx.js45const PDFservicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 createPdfOperation = PDFServicesSdk.CreatePDF.Operation.createNew();1819 // Set operation input from a source file.20 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/createPDFInput.docx');21 createPdfOperation.setInput(input);2223 // Execute the operation and Save the result to the specified location.24 createPdfOperation.execute(executionContext)25 .then(result => result.saveAsFile('output/createPDFFromDOCX.pdf'))26 .catch(err => {27 if(err instanceof PDFServicesSdk.Error.ServiceApiError28 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {29 console.log('Exception encountered while executing operation', err);30 } else {31 console.log('Exception encountered while executing operation', err);32 }33 });34} catch (err) {35 console.log('Exception encountered while executing operation', err);36}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd CreatePDFFromDocx/4// dotnet run CreatePDFFromDocx.csproj56namespace CreatePDFFromDocx7{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 CreatePDFOperation createPdfOperation = CreatePDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef source = FileRef.CreateFromLocalFile(@"createPdfInput.docx");29 createPdfOperation.SetInput(source);3031 // Execute the operation.32 FileRef result = createPdfOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/createPdfOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here. . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.createpdf.CreatePDFFromDOCX45public class CreatePDFFromDOCX {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(CreatePDFFromDOCX .class);910 public static void main(String[] args) {1112 try {1314 // Initial setup, create credentials instance.15 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()16 .withClientId("PDF_SERVICES_CLIENT_ID")17 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")18 .build();1920 //Create an ExecutionContext using credentials and create a new operation instance.21 ExecutionContext executionContext = ExecutionContext.create(credentials);22 CreatePDFOperation createPdfOperation = CreatePDFOperation.createNew();2324 // Set operation input from a source file.25 FileRef source = FileRef.createFromLocalFile("src/main/resources/createPDFInput.docx");26 createPdfOperation.setInput(source);2728 // Execute the operation.29 FileRef result = createPdfOperation.execute(executionContext);3031 // Save the result to the specified location.32 result.saveAs("output/createPDFFromDOCX.pdf");3334 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {35 LOGGER.error("Exception encountered while executing36 operation", ex);37 }38 }39}
Create a PDF file from HTML
Create PDFs from static and dynamic HTML, Zip, and URL.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Html-To-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/htmltopdf' \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 "json": "{}",11 "includeHeaderFooter": true,12 "pageLayout": {13 "pageWidth": 11,14 "pageHeight": 8.515 }16}'1718// Legacy API can be found here19// https://documentcloud.adobe.com/document-services/index.html#post-htmlToPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/createpdf/create-pdf-from-static-html.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const setCustomOptions = (htmlToPDFOperation) => {8 // Define the page layout, in this case an 8 x 11.5 inch page (effectively portrait orientation).9 const pageLayout = new PDFServicesSdk.CreatePDF.options.PageLayout();10 pageLayout.setPageSize(8, 11.5);1112 // Set the desired HTML-to-PDF conversion options.13 const htmlToPdfOptions = new PDFServicesSdk.CreatePDF.options.html.CreatePDFFromHtmlOptions.Builder()14 .includesHeaderFooter(true)15 .withPageLayout(pageLayout)16 .build();17 htmlToPDFOperation.setOptions(htmlToPdfOptions);18};192021try {22 // Initial setup, create credentials instance.23 const credentials = PDFServicesSdk.Credentials24 .servicePrincipalCredentialsBuilder()25 .withClientId("PDF_SERVICES_CLIENT_ID")26 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")27 .build();2829 // Create an ExecutionContext using credentials and create a new operation instance.30 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials), htmlToPDFOperation = PDFServicesSdk.CreatePDF.Operation.createNew();3132 // Set operation input from a source file.33 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/createPDFFromStaticHtmlInput.zip');34 htmlToPDFOperation.setInput(input);3536 // Provide any custom configuration options for the operation.37 setCustomOptions(htmlToPDFOperation);3839 // Execute the operation and Save the result to the specified location.40 htmlToPDFOperation.execute(executionContext)41 .then(result => result.saveAsFile('output/createPdfFromStaticHtmlOutput.pdf'))42 .catch(err => {43 if(err instanceof PDFServicesSdk.Error.ServiceApiError44 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {45 console.log('Exception encountered while executing operation', err);46 } else {47 console.log('Exception encountered while executing operation', err);48 }49 });50} catch (err) {51 console.log('Exception encountered while executing operation', err);52}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd CreatePDFFromStaticHtml/4// dotnet run CreatePDFFromStaticHtml.csproj56namespace CreatePDFFromStaticHtml7{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 CreatePDFOperation htmlToPDFOperation = CreatePDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef source = FileRef.CreateFromLocalFile(@"createPDFFromStaticHtmlInput.zip");29 htmlToPDFOperation.SetInput(source);3031 // Provide any custom configuration options for the operation.32 SetCustomOptions(htmlToPDFOperation);3334 // Execute the operation.35 FileRef result = htmlToPDFOperation.Execute(executionContext);3637 // Save the result to the specified location.38 result.SaveAs(Directory.GetCurrentDirectory() + "/output/createPdfFromStaticHtmlOutput.pdf");39 }40 catch (ServiceUsageException ex)41 {42 log.Error("Exception encountered while executing operation", ex);43 }44 // Catch more errors here. . .45 }4647 private static void SetCustomOptions(CreatePDFOperation htmlToPDFOperation)48 {49 // Define the page layout, in this case an 8 x 11.5 inch page (effectively portrait orientation).50 PageLayout pageLayout = new PageLayout();51 pageLayout.SetPageSize(8, 11.5);5253 // Set the desired HTML-to-PDF conversion options.54 CreatePDFOptions htmlToPdfOptions = CreatePDFOptions.HtmlOptionsBuilder()55 .IncludeHeaderFooter(true)56 .WithPageLayout(pageLayout)57 . Build();58 htmlToPDFOperation.SetOptions(htmlToPdfOptions);59 }6061 static void ConfigureLogging()62 {63 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());64 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));65 }66 }67}
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.createpdf.CreatePDFFromStaticHTML45public class CreatePDFFromStaticHTML {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(CreatePDFFromStaticHTML.class);910 public static void main(String[] args) {1112 try {1314 // Initial setup, create credentials instance.15 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()16 .withClientId("PDF_SERVICES_CLIENT_ID")17 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")18 .build();1920 //Create an ExecutionContext using credentials and create a new operation instance.21 ExecutionContext executionContext = ExecutionContext.create(credentials);22 CreatePDFOperation htmlToPDFOperation = CreatePDFOperation.createNew();2324 // Set operation input from a source file.25 FileRef source = FileRef.createFromLocalFile("src/main/resources/createPDFFromStaticHtmlInput.zip");26 htmlToPDFOperation.setInput(source);2728 // Provide any custom configuration options for the operation.29 setCustomOptions(htmlToPDFOperation);3031 // Execute the operation.32 FileRef result = htmlToPDFOperation.execute(executionContext);3334 // Save the result to the specified location.35 result.saveAs("output/createPDFFromStaticHtmlOutput.pdf");3637 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {38 LOGGER.error("Exception encountered while executing operation", ex);39 }40 }4142 private static void setCustomOptions(CreatePDFOperation htmlToPDFOperation) {43 // Define the page layout, in this case an 8 x 11.5 inch page (effectively portrait orientation).44 PageLayout pageLayout = new PageLayout();45 pageLayout.setPageSize(8, 11.5);4647 // Set the desired HTML-to-PDF conversion options.48 CreatePDFOptions htmlToPdfOptions = CreatePDFOptions.htmlOptionsBuilder()49 .includeHeaderFooter(true)50 .withPageLayout(pageLayout)51 .build();52 htmlToPDFOperation.setOptions(htmlToPdfOptions);53 }54}
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Document-Generation34curl --location --request POST 'https://pdf-services.adobe.io/operation/documentgeneration' \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 "outputFormat": "pdf",11 "jsonDataForMerge": {12 "customerName": "Kane Miller",13 "customerVisits": 100,14 "itemsBought": [15 {16 "name": "Sprays",17 "quantity": 50,18 "amount": 10019 },20 {21 "name": "Chemicals",22 "quantity": 100,23 "amount": 20024 }25 ],26 "totalAmount": 300,27 "previousBalance": 50,28 "lastThreeBillings": [29 100,30 200,31 30032 ],33 "photograph": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP88h8AAu0B9XNPCQQAAAAASUVORK5CYII="34 }35}'3637// Legacy API can be found here38// https://documentcloud.adobe.com/document-services/index.html#post-documentGeneration
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/documentmerge/merge-document-to-pdf.js45 const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Setup input data for the document merge process.16 const jsonString = "{\"customerName\": \"Kane Miller\", \"customerVisits\": 100}",17 jsonDataForMerge = JSON.parse(jsonString);1819 // Create an ExecutionContext using credentials.20 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);2122 // Create a new DocumentMerge options instance.23 const documentMerge = PDFServicesSdk.DocumentMerge,24 documentMergeOptions = documentMerge.options,25 options = new documentMergeOptions.DocumentMergeOptions(jsonDataForMerge, documentMergeOptions.OutputFormat.PDF);2627 // Create a new operation instance using the options instance.28 const documentMergeOperation = documentMerge.Operation.createNew(options);2930 // Set operation input document template from a source file.31 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/documentMergeTemplate.docx');32 documentMergeOperation.setInput(input);3334 // Execute the operation and Save the result to the specified location.35 documentMergeOperation.execute(executionContext)36 .then(result => result.saveAsFile('output/documentMergeOutput.pdf'))37 .catch(err => {38 if(err instanceof PDFServicesSdk.Error.ServiceApiError39 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {40 console.log('Exception encountered while executing operation', err);41 } else {42 console.log('Exception encountered while executing operation', err);43 }44 });45}46catch (err) {47 console.log('Exception encountered while executing operation', err);48}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd MergeDocumentToPDF/4// dotnet run MergeDocumentToPDF.csproj56namespace MergeDocumentToPDF7{8 class Program9 {10 private static readonly ILog log = LogManager.GetLogger(typeof(Program));1112 static void Main()13 {14 //Configure the logging.15 ConfigureLogging();16 try17 {18 // Initial setup, create credentials instance.19 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()20 .WithClientId("PDF_SERVICES_CLIENT_ID")21 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")22 .Build();2324 // Create an ExecutionContext using credentials.25 ExecutionContext executionContext = ExecutionContext.Create(credentials);2627 // Setup input data for the document merge process.28 JObject jsonDataForMerge = JObject.Parse("{\"customerName\": \"Kane Miller\",\"customerVisits\": 100}");2930 // Create a new DocumentMerge Options instance.31 DocumentMergeOptions documentMergeOptions = new DocumentMergeOptions(jsonDataForMerge, OutputFormat.PDF);3233 // Create a new DocumentMerge Operation instance with the DocumentMerge Options instance.34 DocumentMergeOperation documentMergeOperation = DocumentMergeOperation.CreateNew(documentMergeOptions);3536 // Set the operation input document template from a source file.37 documentMergeOperation.SetInput(FileRef.CreateFromLocalFile(@"documentMergeTemplate.docx"));3839 // Execute the operation.40 FileRef result = documentMergeOperation.Execute(executionContext);4142 // Save the result to the specified location.43 result.SaveAs(Directory.GetCurrentDirectory() + "/output/documentMergeOutput.pdf");44 }45 catch (ServiceUsageException ex)46 {47 log.Error("Exception encountered while executing operation", ex);48 }49 catch (ServiceApiException ex)50 {51 log.Error("Exception encountered while executing operation", ex);52 }53 catch (SDKException ex)54 {55 log.Error("Exception encountered while executing operation", ex);56 }57 catch (IOException ex)58 {59 log.Error("Exception encountered while executing operation", ex);60 }61 catch (Exception ex)62 {63 log.Error("Exception encountered while executing operation", ex);64 }65 }6667 static void ConfigureLogging()68 {69 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());70 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));71 }72 }73}
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.documentmerge.MergeDocumentToPDF45package com.adobe.pdfservices.operation.samples.documentmerge;67public class MergeDocumentToPDF {89 // Initialize the logger.10 private static final Logger LOGGER = LoggerFactory.getLogger(MergeDocumentToPDF.class);1112 public static void main(String[] args) {1314 try {1516 // Initial setup, create credentials instance.17 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()18 .withClientId("PDF_SERVICES_CLIENT_ID")19 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")20 .build();2122 // Setup input data for the document merge process.23 JSONObject jsonDataForMerge = new JSONObject("{\"customerName\": \"Kane Miller\",\"customerVisits\": 100}");2425 // Create an ExecutionContext using credentials.26 ExecutionContext executionContext = ExecutionContext.create(credentials);2728 // Create a new DocumentMergeOptions instance.29 DocumentMergeOptions documentMergeOptions = new DocumentMergeOptions(jsonDataForMerge, OutputFormat.PDF);3031 // Create a new DocumentMergeOperation instance with the DocumentMergeOptions instance.32 DocumentMergeOperation documentMergeOperation = DocumentMergeOperation.createNew(documentMergeOptions);3334 // Set the operation input document template from a source file.35 FileRef documentTemplate = FileRef.createFromLocalFile("src/main/resources/documentMergeTemplate.docx");36 documentMergeOperation.setInput(documentTemplate);3738 // Execute the operation.39 FileRef result = documentMergeOperation.execute(executionContext);4041 // Save the result to the specified location.42 result.saveAs("output/documentMergeOutput.pdf");4344 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {45 LOGGER.error("Exception encountered while executing operation", ex);46 }47 }48}
PDF Electronic Seal API
Apply an electronic seal to documents at scale using a certificate issued by certain TSPs (Trust Service Providers) on Adobe’s Approved Trust List (AATL). The electronic seal helps verify the identity and integrity of documents.
See our public API Reference and quickly try our APIs using the Postman collections.
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer-stage.adobe.com/document-services/docs/apis/#tag/PDF-Electronic-Seal34curl --location --request POST 'https://pdf-services.adobe.io/operation/electronicseal' \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 "inputDocumentAssetID": "urn:aaid:AS:UE1:23c30ee0-2c4d-xxxx-xxxx-087832fca718",10 "sealImageAssetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-xxxx-xxxx-087832fca718",11 "sealOptions": {12 "signatureFormat": "PKCS7",13 "cscCredentialOptions": {14 "credentialId": "<CREDENTIAL_ID>",15 "providerName": "<PROVIDER_NAME>",16 "authorizationContext": {17 "tokenType": "Bearer",18 "accessToken": "<ACCESS_TOKEN>"19 },20 "credentialAuthParameters": {21 "pin": "<PIN>"22 }23 },24 "sealFieldOptions": {25 "location": {26 "top": 300,27 "left": 50,28 "right": 250,29 "bottom": 10030 },31 "fieldName": "Signature1",32 "pageNumber": 133 },34 "sealAppearanceOptions": {35 "displayOptions": [36 "NAME",37 "DATE",38 "DISTINGUISHED_NAME",39 "LABELS",40 "SEAL_IMAGE"41 ]42 }43 }44}'
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/electronicseal/electronic-seal.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');6try {7 // Initial setup, create credentials instance.8 const credentials = PDFServicesSdk.Credentials9 .servicePrincipalCredentialsBuilder()10 .withClientId("PDF_SERVICES_CLIENT_ID")11 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")12 .build();1314 // Create an ExecutionContext using credentials15 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1617 const pdfElectronicSeal = PDFServicesSdk.PDFElectronicSeal,18 options = pdfElectronicSeal.options;1920 //Get the input document to perform the sealing operation21 const sourceFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/sampleInvoice.pdf'),2223 //Get the background seal image for signature , if required.24 sealImageFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/sampleSealImage.png');2526 // Set the Seal Field Name to be created in input PDF document.27 sealFieldName = "Signature1";2829 // Set the page number in input document for applying seal.30 sealPageNumber = 1;3132 // Set if seal should be visible or invisible.33 sealVisible = true;3435 //Create FieldLocation instance and set the coordinates for applying signature36 fieldLocation = new options.FieldLocation(150,250,350,200);3738 //Create FieldOptions instance with required details.39 fieldOptions = new options.FieldOptions.Builder(sealFieldName)40 .setFieldLocation(fieldLocation)41 .setPageNumber(sealPageNumber)42 .setVisible(sealVisible)43 .build();4445 //Set the name of TSP Provider being used.46 providerName = "<PROVIDER_NAME>";4748 //Set the access token to be used to access TSP provider hosted APIs.49 accessToken = "<ACCESS_TOKEN>";5051 //Set the credential ID.52 credentialID = "<CREDENTIAL_ID>";5354 //Set the PIN generated while creating credentials.55 pin = "<PIN>";5657 //Create CSCAuthContext instance using access token and token type.58 cscAuthContext = new options.CSCAuthContext(accessToken, "Bearer");5960 //Create CertificateCredentials instance with required certificate details.61 certificateCredentials = options.CertificateCredentials.cscCredentialBuilder()62 .withProviderName(providerName)63 .withCredentialID(credentialID)64 .withPin(pin)65 .withCSCAuthContext(cscAuthContext)66 .build();6768 //Create SealOptions instance with sealing parameters.69 sealOptions = new options.SealOptions.Builder(certificateCredentials, fieldOptions)70 .build()7172 //Create the PDFElectronicSealOperation instance using the SealOptions instance73 const pdfElectronicSealOperation = pdfElectronicSeal.Operation.createNew(sealOptions);7475 //Set the input source file for PDFElectronicSealOperation instance76 pdfElectronicSealOperation.setInput(sourceFile);7778 //Set the optional input seal image for PDFElectronicSealOperation instance79 pdfElectronicSealOperation.setSealImage(sealImageFile);8081 // Execute the operation and Save the result to the specified location.82 pdfElectronicSealOperation.execute(executionContext)83 .then(result => result.saveAsFile("output/ElectronicSeal/sealedOutput.pdf"))84 .catch(err => {85 if(err instanceof PDFServicesSdk.Error.ServiceApiError86 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {87 console.log('Exception encountered while executing operation', err);88 } else {89 console.log('Exception encountered while executing operation', err);90 }91 });
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ElectronicSeal/4// dotnet run ElectronicSeal.csproj56namespace ElectronicSeal7{8 class Program9 {10 // Initialize the logger.11 private static readonly ILog log = LogManager.GetLogger(typeof(Program));12 static void Main()13 {14 //Configure the logging15 ConfigureLogging();1617 try18 {19 // Initial setup, create credentials instance.20 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()21 .WithClientId("PDF_SERVICES_CLIENT_ID")22 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")23 .Build();2425 // Create an ExecutionContext using credentials.26 ExecutionContext executionContext = ExecutionContext.Create(credentials);2728 //Set the input document to perform the sealing operation29 FileRef sourceFile = FileRef.CreateFromLocalFile(@"SampleInvoice.pdf");3031 //Set the background seal image for signature , if required.32 FileRef sealImageFile = FileRef.CreateFromLocalFile(@"sampleSealImage.png");3334 //Set the Seal Field Name to be created in input PDF document.35 string sealFieldName = "Signature1";3637 //Set the page number in input document for applying seal.38 int sealPageNumber = 1;3940 //Set if seal should be visible or invisible.41 bool sealVisible = true;4243 //Create FieldLocation instance and set the coordinates for applying signature44 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);4546 //Create FieldOptions instance with required details.47 FieldOptions sealFieldOptions = new FieldOptions.Builder(sealFieldName)48 .SetVisible(sealVisible)49 .SetFieldLocation(fieldLocation)50 .SetPageNumber(sealPageNumber)51 .Build();5253 //Set the name of TSP Provider being used.54 string providerName = "<PROVIDER_NAME>";5556 //Set the access token to be used to access TSP provider hosted APIs.57 string accessToken = "<ACCESS_TOKEN>";5859 //Set the credential ID.60 string credentialID = "<CREDENTIAL_ID>";6162 //Set the PIN generated while creating credentials.63 string pin = "<PIN>";6465 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");6667 //Create CertificateCredentials instance with required certificate details.68 CertificateCredentials certificateCredentials = CertificateCredentials.CSCCredentialBuilder()69 .WithProviderName(providerName)70 .WithCredentialID(credentialID)71 .WithPin(pin)72 .WithCSCAuthContext(cscAuthContext)73 .Build();7475 //Create SealingOptions instance with all the sealing parameters.76 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, sealFieldOptions).Build();7778 //Create the PDFElectronicSealOperation instance using the PDFElectronicSealOptions instance79 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.CreateNew(sealOptions);8081 //Set the input source file for PDFElectronicSealOperation instance82 pdfElectronicSealOperation.SetInput(sourceFile);8384 //Set the optional input seal image for PDFElectronicSealOperation instance85 pdfElectronicSealOperation.SetSealImage(sealImageFile);8687 //Execute the operation88 FileRef result = pdfElectronicSealOperation.Execute(executionContext);8990 // Save the result to the specified location.91 result.SaveAs("/output/sealedOutput");92 }93 catch (ServiceUsageException ex)94 {95 log.Error("Exception encountered while executing operation", ex);96 }97 catch (ServiceApiException ex)98 {99 log.Error("Exception encountered while executing operation", ex);100 }101 catch (SDKException ex)102 {103 log.Error("Exception encountered while executing operation", ex);104 }105 catch (IOException ex)106 {107 log.Error("Exception encountered while executing operation", ex);108 }109 catch (Exception ex)110 {111 log.Error("Exception encountered while executing operation", ex);112 }113114 }115 static void ConfigureLogging()116 {117 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());118 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));119 }
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.electronicseal.ElectronicSeal45public class ElectronicSeal {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(ElectronicSeal.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials.19 ExecutionContext executionContext = ExecutionContext.create(credentials);2021 //Get the input document to perform the sealing operation22 FileRef sourceFile = FileRef.createFromLocalFile("src/main/resources/sampleInvoice.pdf");2324 //Get the background seal image for signature , if required.25 FileRef sealImageFile = FileRef.createFromLocalFile("src/main/resources/sampleSealImage.png");2627 //Set the Seal Field Name to be created in input PDF document.28 String sealFieldName = "Signature1";2930 //Set the page number in input document for applying seal.31 Integer sealPageNumber = 1;3233 //Set if seal should be visible or invisible.34 Boolean sealVisible = true;3536 //Create FieldLocation instance and set the coordinates for applying signature37 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);3839 //Create FieldOptions instance with required details.40 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)41 .setFieldLocation(fieldLocation)42 .setPageNumber(sealPageNumber)43 .setVisible(sealVisible)44 .build();4546 //Set the name of TSP Provider being used.47 String providerName = "<PROVIDER_NAME>";4849 //Set the access token to be used to access TSP provider hosted APIs.50 String accessToken = "<ACCESS_TOKEN>";5152 //Set the credential ID.53 String credentialID = "<CREDENTIAL_ID>";5455 //Set the PIN generated while creating credentials.56 String pin = "<PIN>";5758 //Create CSCAuthContext instance using access token and token type.59 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");6061 //Create CertificateCredentials instance with required certificate details.62 CertificateCredentials certificateCredentials = CertificateCredentials.cscCredentialBuilder()63 .withProviderName(providerName)64 .withCredentialID(credentialID)65 .withPin(pin)66 .withCSCAuthContext(cscAuthContext)67 .build();6869 //Create SealOptions instance with sealing parameters.70 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, fieldOptions).build();7172 //Create the PDFElectronicSealOperation instance using the SealOptions instance73 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.createNew(sealOptions);7475 //Set the input source file for PDFElectronicSealOperation instance76 pdfElectronicSealOperation.setInput(sourceFile);7778 //Set the optional input seal image for PDFElectronicSealOperation instance79 pdfElectronicSealOperation.setSealImage(sealImageFile);8081 //Execute the operation82 FileRef result = pdfElectronicSealOperation.execute(executionContext);8384 //Save the output at specified location85 result.saveAs("output/ElectronicSeal/sealedOutput.pdf");868788 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {89 LOGGER.error("Exception encountered while executing operation", ex);90 }91 }
Convert a PDF file to other formats
Convert existing PDFs to popular formats, such as Microsoft Word, Excel, and PowerPoint, as well as text and image
Support for PDF to DOC, PDF to DOCX, PDF to JPEG, PDF to PNG, PDF to PPTX, PDF to RTF, PDF to XLSX
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Export-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/exportpdf' \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 "targetFormat": "docx"11}'1213// Legacy API can be found here14// https://documentcloud.adobe.com/document-services/index.html#post-exportPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/exportpdf/export-pdf-to-docx.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 //Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 exportPDF = PDFServicesSdk.ExportPDF,18 exportPdfOperation = exportPDF.Operation.createNew(exportPDF.SupportedTargetFormats.DOCX);1920 // Set operation input from a source file21 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/exportPDFInput.pdf');22 exportPdfOperation.setInput(input);2324 // Execute the operation and Save the result to the specified location.25 exportPdfOperation.execute(executionContext)26 .then(result => result.saveAsFile('output/exportPdfOutput.docx'))27 .catch(err => {28 if(err instanceof PDFServicesSdk.Error.ServiceApiError29 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {30 console.log('Exception encountered while executing operation', err);31 } else {32 console.log('Exception encountered while executing operation', err);33 }34 });35} catch (err) {36 console.log('Exception encountered while executing operation', err);37}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ExportPDFToDocx/4// dotnet run ExportPDFToDocx.csproj56 namespace ExportPDFToDocx7{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 ExportPDFOperation exportPdfOperation = ExportPDFOperation.CreateNew(ExportPDFTargetFormat.DOCX);2627 // Set operation input from a local PDF file28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"exportPdfInput.pdf");29 exportPdfOperation.SetInput(sourceFileRef);3031 // Execute the operation.32 FileRef result = exportPdfOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/exportPdfOutput.docx");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here. . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.exportpdf.ExportPDFToDOCX45public class ExportPDFToDOCX {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(ExportPDFToDOCX.class);910 public static void main(String[] args) {1112 try {13 // Initial setup, create credentials instance.14 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()15 .withClientId("PDF_SERVICES_CLIENT_ID")16 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")17 .build();18 //Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 ExportPDFOperation exportPdfOperation = ExportPDFOperation.createNew(ExportPDFTargetFormat.DOCX);2122 // Set operation input from a local PDF file23 FileRef sourceFileRef = FileRef.createFromLocalFile("src/main/resources/exportPDFInput.pdf");24 exportPdfOperation.setInput(sourceFileRef);2526 // Execute the operation.27 FileRef result = exportPdfOperation.execute(executionContext);2829 // Save the result to the specified location.30 result.saveAs("output/exportPdfOutput.docx");3132 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {33 LOGGER.error("Exception encountered while executing operation", ex);34 }35 }36}
OCR a PDF file
Use built-in optical character recognition (OCR) to convert images to text and enable fully text searchable documents for archiving and creation of searchable indexes.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Ocr34curl --location --request POST 'https://pdf-services.adobe.io/operation/ocr' \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}'1112// Legacy API can be found here13// https://documentcloud.adobe.com/document-services/index.html#post-ocr
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/ocr/ocr-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 ocrOperation = PDFServicesSdk.OCR.Operation.createNew();1819 // Set operation input from a source file.20 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/ocrInput.pdf');21 ocrOperation.setInput(input);2223 // Execute the operation and Save the result to the specified location.24 ocrOperation.execute(executionContext)25 .then(result => result.saveAsFile('output/ocrOutput.pdf'))26 .catch(err => {27 if(err instanceof PDFServicesSdk.Error.ServiceApiError28 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {29 console.log('Exception encountered while executing operation', err);30 } else {31 console.log('Exception encountered while executing operation', err);32 }33 });34} catch (err) {35 console.log('Exception encountered while executing operation', err);36}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd OcrPDF/4// dotnet run OcrPDF.csproj56namespace OcrPDF7{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 OCROperation ocrOperation = OCROperation.CreateNew();2627 // Set operation input from a source file.28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"ocrInput.pdf");29 ocrOperation.SetInput(sourceFileRef);3031 // Execute the operation.32 FileRef result = ocrOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/ocrOperationOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here. . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.ocrpdf.OcrPDF45public class OcrPDF {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(OcrPDF.class);910 public static void main(String[] args) {1112 try {1314 // Initial setup, create credentials instance.15 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()16 .withClientId("PDF_SERVICES_CLIENT_ID")17 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")18 .build();1920 //Create an ExecutionContext using credentials and create a new operation instance.21 ExecutionContext executionContext = ExecutionContext.create(credentials);22 OCROperation ocrOperation = OCROperation.createNew();2324 // Set operation input from a source file.25 FileRef source = FileRef.createFromLocalFile("src/main/resources/ocrInput.pdf");26 ocrOperation.setInput(source);2728 // Execute the operation29 FileRef result = ocrOperation.execute(executionContext);3031 // Save the result at the specified location32 result.saveAs("output/ocrOutput.pdf");3334 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {35 LOGGER.error("Exception encountered while executing operation", ex);36 }37 }38}
Secure a PDf file and set restrictions
Secure a PDF file with a password encrypt the document. Set an owner password and restrictions on certain features like printing, editing and copying in the PDF document to prevent end users from modifying it.
Support for AES-128 and AES-256 encryption on PDF files, with granular permissions for high and low quality printing and fill and sign form field restrictions.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Protect-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/protectpdf' \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 "passwordProtection": {10 "userPassword": "user_password"11 },12 "encryptionAlgorithm": "AES_128",13 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718"14}'1516// Legacy API can be found here17// https://documentcloud.adobe.com/document-services/index.html#post-protectPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/protectpdf/protect-pdf.js45 const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67 try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 // Build ProtectPDF options by setting a User Password and Encryption Algorithm (used for encrypting the PDF file).19 const protectPDF = PDFServicesSdk.ProtectPDF,20 options = new protectPDF.options.PasswordProtectOptions.Builder()21 .setUserPassword("encryptPassword")22 .setEncryptionAlgorithm(PDFServicesSdk.ProtectPDF.options.EncryptionAlgorithm.AES_256)23 .build();2425 // Create a new operation instance.26 const protectPDFOperation = protectPDF.Operation.createNew(options);2728 // Set operation input from a source file.29 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/protectPDFInput.pdf');30 protectPDFOperation.setInput(input);3132 // Execute the operation and Save the result to the specified location.33 protectPDFOperation.execute(executionContext)34 .then(result => result.saveAsFile('output/protectPDFOutput.pdf'))35 .catch(err => {36 if(err instanceof PDFServicesSdk.Error.ServiceApiError37 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {38 console.log('Exception encountered while executing operation', err);39 } else {40 console.log('Exception encountered while executing operation', err);41 }42 });43 } catch (err) {44 console.log('Exception encountered while executing operation', err);45}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ProtectPDF/4// dotnet run ProtectPDF.csproj56namespace ProtectPDF7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Build ProtectPDF options by setting a User Password and Encryption Algorithm (used for encrypting the PDF file).27 ProtectPDFOptions protectPDFOptions = ProtectPDFOptions.PasswordProtectOptionsBuilder()28 .SetUserPassword("encryptPassword")29 .SetEncryptionAlgorithm(EncryptionAlgorithm.AES_256)30 .Build();3132 // Create a new operation instance33 ProtectPDFOperation protectPDFOperation = ProtectPDFOperation.CreateNew(protectPDFOptions);3435 // Set operation input from a source file.36 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"protectPDFInput.pdf");37 protectPDFOperation.SetInput(sourceFileRef);3839 // Execute the operation.40 FileRef result = protectPDFOperation.Execute(executionContext);4142 // Save the result to the specified location.43 result.SaveAs(Directory.GetCurrentDirectory() + "/output/protectPDFOutput.pdf");44 }45 catch (ServiceUsageException ex)46 {47 log.Error("Exception encountered while executing operation", ex);48 }49 // Catch more errors here . . .50 }5152 static void ConfigureLogging()53 {54 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());55 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));56 }57 }58}
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.protectpdf.ProtectPDF45public class ProtectPDF {6 // Initialize the logger.7 private static final Logger LOGGER = LoggerFactory.getLogger(ProtectPDF.class);89 public static void main(String[] args) {1011 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials.19 ExecutionContext executionContext = ExecutionContext.create(credentials);2021 // Build ProtectPDF options by setting a User Password and Encryption Algorithm (used for encrypting the PDF file).22 ProtectPDFOptions protectPDFOptions = ProtectPDFOptions.passwordProtectOptionsBuilder()23 .setUserPassword("encryptPassword")24 .setEncryptionAlgorithm(EncryptionAlgorithm.AES_256)25 .build();2627 // Create a new operation instance.28 ProtectPDFOperation protectPDFOperation = ProtectPDFOperation.createNew(protectPDFOptions);2930 // Set operation input from a source file.31 FileRef source = FileRef.createFromLocalFile("src/main/resources/protectPDFInput.pdf");32 protectPDFOperation.setInput(source);3334 // Execute the operation35 FileRef result = protectPDFOperation.execute(executionContext);3637 // Save the result at the specified location38 result.saveAs("output/protectPDFOutput.pdf");3940 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {41 LOGGER.error("Exception encountered while executing operation", ex);42 }43 }44}
Remove the password from a PDF file
Remove password security from a PDF document. This can only be accomplished with the owner password of the document which must be passed in the operation.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Remove-Protection34curl --location --request POST 'https://pdf-services.adobe.io/operation/removeprotection' \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 "password": "mypassword",10 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718"11}'1213// Legacy API can be found here14// https://documentcloud.adobe.com/document-services/index.html#post-removeProtection
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/removeprotection/remove-protection.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 // Create a new operation instance.19 const removeProtectionOperation = PDFServicesSdk.RemoveProtection.Operation.createNew(),20 input = PDFServicesSdk.FileRef.createFromLocalFile(21 'resources/removeProtectionInput.pdf',22 PDFServicesSdk.RemoveProtection.SupportedSourceFormat.pdf23 );24 // Set operation input from a source file.25 removeProtectionOperation.setInput(input);2627 // Set the password for removing security from a PDF document.28 removeProtectionOperation.setPassword("password");2930 // Execute the operation and Save the result to the specified location.31 removeProtectionOperation.execute(executionContext)32 .then(result => result.saveAsFile('output/removeProtectionOutput.pdf'))33 .catch(err => {34 if(err instanceof PDFServicesSdk.Error.ServiceApiError35 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {36 console.log('Exception encountered while executing operation', err);37 } else {38 console.log('Exception encountered while executing operation', err);39 }40 });41} catch (err) {42 console.log('Exception encountered while executing operation', err);43}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd RemoveProtection/4// dotnet run RemoveProtection.csproj56namespace RemoveProtection7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"removeProtectionInput.pdf");31 removeProtectionOperation.SetInput(sourceFileRef);3233 // Set the password for removing security from a PDF document.34 removeProtectionOperation.SetPassword("password");3536 // Execute the operation.37 FileRef result = removeProtectionOperation.Execute(executionContext);3839 // Save the result to the specified location.40 result.SaveAs(Directory.GetCurrentDirectory() + "/output/removeProtectionOutput.pdf");41 }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 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.removeprotection.RemoveProtection45public class RemoveProtection {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(RemoveProtection.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/removeProtectionInput.pdf");24 removeProtectionOperation.setInput(source);2526 // Set the password for removing security from a PDF document.27 removeProtectionOperation.setPassword("password");2829 // Execute the operation.30 FileRef result = removeProtectionOperation.execute(executionContext);3132 // Save the result to the specified location.33 result.saveAs("output/removeProtectionOutput.pdf");3435 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {36 LOGGER.error("Exception encountered while executing operation", e);37 }38 }39}
Get the properties of a PDF file
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.
See our public API Reference and quickly try our APIs using the Postman collections
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}'1213// Legacy API can be found here14// https://documentcloud.adobe.com/document-services/index.html#post-pdfProperties
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/exportpdf/get-pdf-properties.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 //Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 pdfPropertiesOperation = PDFServicesSdk.PDFProperties.Operation.createNew();1819 // Set operation input from a source file.20 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/pdfPropertiesInput.pdf');21 pdfPropertiesOperation.setInput(input);2223 // Provide any custom configuration options for the operation.24 const options = new PDFServicesSdk.PDFProperties.options.PDFPropertiesOptions.Builder()25 .includePageLevelProperties(true)26 .build();27 pdfPropertiesOperation.setOptions(options);2829 // Execute the operation ang get properties of the PDF in PDFProperties object.30 pdfPropertiesOperation.execute(executionContext)31 .then(result => console.log("The resultant json object is : " + JSON.stringify(result, null, 4)))32 .catch(err => {33 if(err instanceof PDFServicesSdk.Error.ServiceApiError34 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {35 console.log('Exception encountered while executing operation', err);36 } else {37 console.log('Exception encountered while executing operation', err);38 }39 });40} catch (err) {41 console.log('Exception encountered while executing operation', err);42}
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 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.GetPDFProperties45public 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 {1314 // Initial setup, create credentials instance.15 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()16 .withClientId("PDF_SERVICES_CLIENT_ID")17 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")18 .build();1920 //Create an ExecutionContext using credentials and create a new operation instance.21 ExecutionContext executionContext = ExecutionContext.create(credentials);22 PDFPropertiesOperation pdfPropertiesOperation = PDFPropertiesOperation.createNew();2324 // Provide an input FileRef for the operation25 FileRef source = FileRef.createFromLocalFile("src/main/resources/pdfPropertiesInput.pdf");26 pdfPropertiesOperation.setInputFile(source);2728 // Build PDF Properties options to include page level properties and set them into the operation29 PDFPropertiesOptions pdfPropertiesOptions = PDFPropertiesOptions.PDFPropertiesOptionsBuilder()30 .includePageLevelProperties(true)31 .build();32 pdfPropertiesOperation.setOptions(pdfPropertiesOptions);3334 // Execute the operation ang get properties of the PDF in PDFProperties object.35 PDFProperties result = pdfPropertiesOperation.execute(executionContext);3637 // Get properties of the PDF38 LOGGER.info("The Page level properties of the PDF: {}", result.getDocument().getPageCount());39 LOGGER.info("The Fonts used in the PDF: ");40 for(Font font: result.getDocument().getFonts()) {41 LOGGER.info(font.getName());42 }4344 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {45 LOGGER.error("Exception encountered while executing operation", ex);46 }47 }48}
Split a PDF into multiple files
Split a PDF document into multiple smaller documents by simply specifying either the number of files, pages per file, or page ranges.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Split-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/splitpdf' \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 "splitoption": {11 "pageCount": 912 }13}'1415// Legacy API can be found here16// https://documentcloud.adobe.com/document-services/index.html#post-splitPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/splitpdf/split-pdf-by-number-of-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 // Create a new operation instance.19 const splitPDFOperation = PDFServicesSdk.SplitPDF.Operation.createNew(),20 input = PDFServicesSdk.FileRef.createFromLocalFile(21 'resources/splitPDFInput.pdf',22 PDFServicesSdk.SplitPDF.SupportedSourceFormat.pdf23 );24 // Set operation input from a source file.25 splitPDFOperation.setInput(input);2627 // Set the maximum number of pages each of the output files can have.28 splitPDFOperation.setPageCount(2);2930 // Execute the operation and Save the result to the specified location.31 splitPDFOperation.execute(executionContext)32 .then(result => {33 let saveFilesPromises = [];34 for(let i = 0; i < result.length; i++){35 saveFilesPromises.push(result[i].saveAsFile(`output/SplitPDFByNumberOfPagesOutput_${i}.pdf`));36 }37 return Promise.all(saveFilesPromises);38 })39 .catch(err => {40 if(err instanceof PDFServicesSdk.Error.ServiceApiError41 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {42 console.log('Exception encountered while executing operation', err);43 } else {44 console.log('Exception encountered while executing operation', err);45 }46 });47} catch (err) {48 console.log('Exception encountered while executing operation', err);49}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd SplitPDFByNumberOfPages/4// dotnet run SplitPDFByNumberOfPages.csproj56namespace SplitPDFByNumberOfPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 SplitPDFOperation splitPDFOperation = SplitPDFOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"splitPDFInput.pdf");31 splitPDFOperation.SetInput(sourceFileRef);3233 // Set the maximum number of pages each of the output files can have.34 splitPDFOperation.SetPageCount(2);3536 // Execute the operation.37 List result = splitPDFOperation.Execute(executionContext);3839 // Save the result to the specified location.40 int index = 0;41 foreach (FileRef fileRef in result)42 {43 fileRef.SaveAs(Directory.GetCurrentDirectory() + "/output/SplitPDFByNumberOfPagesOutput_" + index + ".pdf");44 index++;45 }4647 }48 catch (ServiceUsageException ex)49 {50 log.Error("Exception encountered while executing operation", ex);51 }52 // Catch more errors here . . .53 }5455 static void ConfigureLogging()56 {57 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());58 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));59 }60 }61}
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.splitpdf.SplitPDFByNumberOfPages45public class SplitPDFByNumberOfPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(SplitPDFByNumberOfPages.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 SplitPDFOperation splitPDFOperation = SplitPDFOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/splitPDFInput.pdf");24 splitPDFOperation.setInput(source);2526 // Set the maximum number of pages each of the output files can have.27 splitPDFOperation.setPageCount(2);2829 // Execute the operation.30 List result = splitPDFOperation.execute(executionContext);3132 // Save the result to the specified location.33 int index = 0;34 for (FileRef fileRef : result) {35 fileRef.saveAs("output/SplitPDFByNumberOfPagesOutput_" + index + ".pdf");36 index++;37 }3839 } catch (IOException| ServiceApiException | SdkException | ServiceUsageException e) {40 LOGGER.error("Exception encountered while executing operation", e);41 }42 }4344}
Combine multiple documents into a pdf file
Combine two or more documents into a single PDF file
See our public API Reference and quickly try our APIs using the Postman collections.
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Combine-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/combinepdf' \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 "assets": [10 {11 "assetID": "urn:aaid:AS:UE1:23c30ee0-2c4d-46d6-87f2-087832fca718"12 },13 {14 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718"15 }16 ]17}'1819// Legacy API can be found here20// https://documentcloud.adobe.com/document-services/index.html#post-combinePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/combinepdf/combine-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 combineFilesOperation = PDFServicesSdk.CombineFiles.Operation.createNew();1819 // Set operation input from a source file.20 const combineSource1 = PDFServicesSdk.FileRef.createFromLocalFile('resources/combineFilesInput1.pdf'),21 combineSource2 = PDFServicesSdk.FileRef.createFromLocalFile('resources/combineFilesInput2.pdf');22 combineFilesOperation.addInput(combineSource1);23 combineFilesOperation.addInput(combineSource2);2425 // Execute the operation and Save the result to the specified location.26 combineFilesOperation.execute(executionContext)27 .then(result => result.saveAsFile('output/combineFilesOutput.pdf'))28 .catch(err => {29 if (err instanceof PDFServicesSdk.Error.ServiceApiError30 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {31 console.log('Exception encountered while executing operation', err);32 } else {33 console.log('Exception encountered while executing operation', err);34 }35 });36} catch (err) {37 console.log('Exception encountered while executing operation', err);38}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd CombinePDF/4// dotnet run CombinePDF.csproj56namespace CombinePDF7{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 CombineFilesOperation combineFilesOperation = CombineFilesOperation.CreateNew();2627 // Add operation input from source files.28 FileRef combineSource1 = FileRef.CreateFromLocalFile(@"combineFilesInput1.pdf");29 FileRef combineSource2 = FileRef.CreateFromLocalFile(@"combineFilesInput2.pdf");30 combineFilesOperation.AddInput(combineSource1);31 combineFilesOperation.AddInput(combineSource2);3233 // Execute the operation.34 FileRef result = combineFilesOperation.Execute(executionContext);3536 // Save the result to the specified location.37 result.SaveAs(Directory.GetCurrentDirectory() + "/output/combineFilesOutput.pdf");3839 }40 catch (ServiceUsageException ex)41 {42 log.Error("Exception encountered while executing operation", ex);43 }44 // Catch more errors here. . .45 }4647 static void ConfigureLogging()48 {49 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());50 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));51 }52 }53}
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.combinepdf.CombinePDF45public class CombinePDF {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(CombinePDF.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 //Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 CombineFilesOperation combineFilesOperation = CombineFilesOperation.createNew();2122 // Add operation input from source files.23 FileRef combineSource1 = FileRef.createFromLocalFile("src/main/resources/combineFilesInput1.pdf");24 FileRef combineSource2 = FileRef.createFromLocalFile("src/main/resources/combineFilesInput2.pdf");25 combineFilesOperation.addInput(combineSource1);26 combineFilesOperation.addInput(combineSource2);2728 // Execute the operation.29 FileRef result = combineFilesOperation.execute(executionContext);3031 // Save the result to the specified location.32 result.saveAs("output/combineFilesOutput.pdf");3334 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {35 LOGGER.error("Exception encountered while executing operation", e);36 }37 }38}
Compress a pdf file
Reduce the size of PDF files by compressing to smaller sizes for lower bandwidth viewing, downloading, and sharing.
Support for multiple compression levels to retain the quality of images and graphics
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Compress-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/compresspdf' \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}'1112// Legacy API can be found here13// https://documentcloud.adobe.com/document-services/index.html#post-compressPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/compresspdf/compress-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 compressPDF = PDFServicesSdk.CompressPDF,18 compressPDFOperation = compressPDF.Operation.createNew();1920 // Set operation input from a source file.21 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/compressPDFInput.pdf');22 compressPDFOperation.setInput(input);2324 // Execute the operation and Save the result to the specified location.25 compressPDFOperation.execute(executionContext)26 .then(result => result.saveAsFile('output/compressPDFOutput.pdf'))27 .catch(err => {28 if(err instanceof PDFServicesSdk.Error.ServiceApiError29 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {30 console.log('Exception encountered while executing operation', err);31 } else {32 console.log('Exception encountered while executing operation', err);33 }34 });35} catch (err) {36 console.log('Exception encountered while executing operation', err);37}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd CompressPDF/4// dotnet run CompressPDF.csproj56namespace CompressPDF7{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 CompressPDFOperation compressPDFOperation = CompressPDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"compressPDFInput.pdf");29 compressPDFOperation.SetInput(sourceFileRef);3031 // Execute the operation.32 FileRef result = compressPDFOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/compressPDFOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here . . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.compresspdf.CompressPDF45public class CompressPDF {6 // Initialize the logger.7 private static final Logger LOGGER = LoggerFactory.getLogger(CompressPDF.class);89 public static void main(String[] args) {1011 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 CompressPDFOperation compressPDFOperation = CompressPDFOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/compressPDFInput.pdf");24 compressPDFOperation.setInput(source);2526 // Execute the operation27 FileRef result = compressPDFOperation.execute(executionContext);2829 // Save the result at the specified location30 result.saveAs("output/compressPDFOutput.pdf");3132 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {33 LOGGER.error("Exception encountered while executing operation", ex);34 }35 }36}
Reorder pages within PDF files
Reorder the pages of a PDF file to reorganize.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Combine-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/combinepdf' \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 "assets": [10 {11 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",12 "pageRanges": [13 {14 "start": 3,15 "end": 316 },17 {18 "start": 1,19 "end": 120 },21 {22 "start": 4,23 "end": 424 }25 ]26 }27 ]28}'2930// Legacy API can be found here31// https://documentcloud.adobe.com/document-services/index.html#post-combinePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/reorderpages/reorder-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getPageRangeForReorder = () => {8 // Specify order of the pages for an output document.9 const pageRanges = new PDFServicesSdk.PageRanges();1011 // Add pages 3 to 4.12 pageRanges.addPageRange(3, 4);1314 // Add page 1.15 pageRanges.addSinglePage(1);1617 return pageRanges;18};19try {20 // Initial setup, create credentials instance.21 const credentials = PDFServicesSdk.Credentials22 .servicePrincipalCredentialsBuilder()23 .withClientId("PDF_SERVICES_CLIENT_ID")24 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")25 .build();2627 // Create an ExecutionContext using credentials and create a new operation instance.28 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),29 reorderPagesOperation = PDFServicesSdk.ReorderPages.Operation.createNew();3031 // Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.32 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/reorderPagesInput.pdf');33 const pageRanges = getPageRangeForReorder();34 reorderPagesOperation.setInput(input);35 reorderPagesOperation.setPagesOrder(pageRanges);3637 // Execute the operation and Save the result to the specified location.38 reorderPagesOperation.execute(executionContext)39 .then(result => result.saveAsFile('output/reorderPagesOutput.pdf'))40 .catch(err => {41 if(err instanceof PDFServicesSdk.Error.ServiceApiError42 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {43 console.log('Exception encountered while executing operation', err);44 } else {45 console.log('Exception encountered while executing operation', err);46 }47 });48} catch (err) {49 console.log('Exception encountered while executing operation', err);50}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ReorderPages/4// dotnet run ReorderPDFPages.csproj56namespace ReorderPDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 ReorderPagesOperation reorderPagesOperation = ReorderPagesOperation.CreateNew();2829 // Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"reorderPagesInput.pdf");31 reorderPagesOperation.SetInput(sourceFileRef);32 PageRanges pageRanges = GetPageRangeForReorder();33 reorderPagesOperation.SetPagesOrder(pageRanges);3435 // Execute the operation.36 FileRef result = reorderPagesOperation.Execute(executionContext);3738 // Save the result to the specified location.39 result.SaveAs(Directory.GetCurrentDirectory() + "/output/reorderPagesOutput.pdf");40 }41 catch (ServiceUsageException ex)42 {43 log.Error("Exception encountered while executing operation", ex);44 }45 // Catch more errors here . . .46 }4748 private static PageRanges GetPageRangeForReorder()49 {50 // Specify order of the pages for an output document.51 PageRanges pageRanges = new PageRanges();52 // Add pages 3 to 4.53 pageRanges.AddRange(3, 4);5455 // Add page 1.56 pageRanges.AddSinglePage(1);5758 return pageRanges;59 }6061 static void ConfigureLogging()62 {63 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());64 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));65 }66 }67}
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.reorderpages.ReorderPDFPages45public class ReorderPDFPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(ReorderPDFPages.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 ReorderPagesOperation reorderPagesOperation = ReorderPagesOperation.createNew();2122 // Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/reorderPagesInput.pdf");24 PageRanges pageRanges = getPageRangeForReorder();25 reorderPagesOperation.setInput(source);26 reorderPagesOperation.setPagesOrder(pageRanges);2728 // Execute the operation.29 FileRef result = reorderPagesOperation.execute(executionContext);3031 // Save the result to the specified location.32 result.saveAs("output/reorderPagesOutput.pdf");3334 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {35 LOGGER.error("Exception encountered while executing operation", e);36 }37 }3839 private static PageRanges getPageRangeForReorder() {40 // Specify order of the pages for an output document.41 PageRanges pageRanges = new PageRanges();42 // Add pages 3 to 4.43 pageRanges.addRange(3, 4);4445 // Add page 1.46 pageRanges.addSinglePage(1);4748 return pageRanges;49 }50}
Linearize a PDF file for fast web view
Optimize PDFs for quick viewing on the web, especially for mobile clients. Linearization allows your end users to view large PDF documents incrementally so that they can view pages much faster in lower bandwidth conditions.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Linearize-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/linearizepdf' \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}'1112// Legacy API can be found here13// https://documentcloud.adobe.com/document-services/index.html#post-linearizePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/linearizepdf/linearize-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 linearizePDF = PDFServicesSdk.LinearizePDF,18 linearizePDFOperation = linearizePDF.Operation.createNew();1920 // Set operation input from a source file.21 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/linearizePDFInput.pdf');22 linearizePDFOperation.setInput(input);2324 // Execute the operation and Save the result to the specified location.25 linearizePDFOperation.execute(executionContext)26 .then(result => result.saveAsFile('output/linearizePDFOutput.pdf'))27 .catch(err => {28 if(err instanceof PDFServicesSdk.Error.ServiceApiError29 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {30 console.log('Exception encountered while executing operation', err);31 } else {32 console.log('Exception encountered while executing operation', err);33 }34 });35} catch (err) {36 console.log('Exception encountered while executing operation', err);37}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd LinearizePDF/4// dotnet run LinearizePDF.csproj56namespace LinearizePDF7{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 LinearizePDFOperation linearizePDFOperation = LinearizePDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"linearizePDFInput.pdf");29 linearizePDFOperation.SetInput(sourceFileRef);3031 // Execute the operation.32 FileRef result = linearizePDFOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/linearizePDFOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here . . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.linearizepdf.LinearizePDF45public class LinearizePDF {6 // Initialize the logger.7 private static final Logger LOGGER = LoggerFactory.getLogger(LinearizePDF.class);89 public static void main(String[] args) {1011 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 LinearizePDFOperation linearizePDFOperation = LinearizePDFOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/linearizePDFInput.pdf");24 linearizePDFOperation.setInput(source);2526 // Execute the operation27 FileRef result = linearizePDFOperation.execute(executionContext);2829 // Save the result at the specified location30 result.saveAs("output/linearizePDFOutput.pdf");3132 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {33 LOGGER.error("Exception encountered while executing operation", ex);34 }35 }36}
Insert a page into a PDF document
Insert one or more pages into an existing document
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Combine-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/combinepdf' \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 "assets": [10 {11 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",12 "pageRanges": [13 {14 "start": 1,15 "end": 116 }17 ]18 },19 {20 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",21 "pageRanges": [22 {23 "start": 424 }25 ]26 },27 {28 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",29 "pageRanges": [30 {31 "start": 132 }33 ]34 },35 {36 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",37 "pageRanges": [38 {39 "start": 240 }41 ]42 }43 ]44}'4546// Legacy API can be found here47// https://documentcloud.adobe.com/document-services/index.html#post-combinePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/insertpages/insert-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getPageRangesForFirstFile = () => {8 // Specify which pages of the first file are to be inserted in the base file.9 const pageRangesForFirstFile = new PDFServicesSdk.PageRanges();10 // Add pages 1 to 3.11 pageRangesForFirstFile.addPageRange(1, 3);1213 // Add page 4.14 pageRangesForFirstFile.addSinglePage(4);1516 return pageRangesForFirstFile;17};1819try {20 // Initial setup, create credentials instance.21 const credentials = PDFServicesSdk.Credentials22 .servicePrincipalCredentialsBuilder()23 .withClientId("PDF_SERVICES_CLIENT_ID")24 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")25 .build();2627 // Create an ExecutionContext using credentials and create a new operation instance.28 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),29 insertPagesOperation = PDFServicesSdk.InsertPages.Operation.createNew();3031 // Set operation base input from a source file.32 const baseInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/baseInput.pdf');33 insertPagesOperation.setBaseInput(baseInputFile);3435 // Create a FileRef instance using a local file.36 const firstFileToInsert = PDFServicesSdk.FileRef.createFromLocalFile('resources/firstFileToInsertInput.pdf'),37 pageRanges = getPageRangesForFirstFile();3839 // Adds the pages (specified by the page ranges) of the input PDF file to be inserted at the specified page of the base PDF file.40 insertPagesOperation.addPagesToInsertAt(2, firstFileToInsert, pageRanges);4142 // Create a FileRef instance using a local file.43 const secondFileToInsert = PDFServicesSdk.FileRef.createFromLocalFile('resources/secondFileToInsertInput.pdf');4445 // Adds all the pages of the input PDF file to be inserted at the specified page of the base PDF file.46 insertPagesOperation.addPagesToInsertAt(3, secondFileToInsert);4748 // Execute the operation and Save the result to the specified location.49 insertPagesOperation.execute(executionContext)50 .then(result => result.saveAsFile('output/insertPagesOutput.pdf'))51 .catch(err => {52 if (err instanceof PDFServicesSdk.Error.ServiceApiError53 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {54 console.log('Exception encountered while executing operation', err);55 } else {56 console.log('Exception encountered while executing operation', err);57 }58 });59} catch (err) {60 console.log('Exception encountered while executing operation', err);61}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd InsertPDFPages/4// dotnet run InsertPDFPages.csproj56namespace InsertPDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 InsertPagesOperation insertPagesOperation = InsertPagesOperation.CreateNew();2829 // Set operation base input from a source file.30 FileRef baseSourceFile = FileRef.CreateFromLocalFile(@"baseInput.pdf");31 insertPagesOperation.SetBaseInput(baseSourceFile);3233 // Create a FileRef instance using a local file.34 FileRef firstFileToInsert = FileRef.CreateFromLocalFile(@"firstFileToInsertInput.pdf");35 PageRanges pageRanges = GetPageRangeForFirstFile();3637 // Adds the pages (specified by the page ranges) of the input PDF file to be inserted at the specified page of the base PDF file.38 insertPagesOperation.AddPagesToInsertAt(firstFileToInsert, pageRanges, 2);3940 // Create a FileRef instance using a local file.41 FileRef secondFileToInsert = FileRef.CreateFromLocalFile(@"secondFileToInsertInput.pdf");4243 // Adds all the pages of the input PDF file to be inserted at the specified page of the base PDF file.44 insertPagesOperation.AddPagesToInsertAt(secondFileToInsert, 3);4546 // Execute the operation.47 FileRef result = insertPagesOperation.Execute(executionContext);4849 // Save the result to the specified location.50 result.SaveAs(Directory.GetCurrentDirectory() + "/output/insertPagesOutput.pdf");51 }52 catch (ServiceUsageException ex)53 {54 log.Error("Exception encountered while executing operation", ex);55 // Catch more errors here . . .56 }5758 private static PageRanges GetPageRangeForFirstFile()59 {60 // Specify which pages of the first file are to be inserted in the base file.61 PageRanges pageRanges = new PageRanges();62 // Add pages 1 to 3.63 pageRanges.AddRange(1, 3);6465 // Add page 4.66 pageRanges.AddSinglePage(4);6768 return pageRanges;69 }7071 static void ConfigureLogging()72 {73 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());74 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));75 }76 }77}
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.insertpages.InsertPDFPages45public class InsertPDFPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(InsertPDFPages.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 InsertPagesOperation insertPagesOperation = InsertPagesOperation.createNew();2122 // Set operation base input from a source file.23 FileRef baseSourceFile = FileRef.createFromLocalFile("src/main/resources/baseInput.pdf");24 insertPagesOperation.setBaseInput(baseSourceFile);2526 // Create a FileRef instance using a local file.27 FileRef firstFileToInsert = FileRef.createFromLocalFile("src/main/resources/firstFileToInsertInput.pdf");28 PageRanges pageRanges = getPageRangeForFirstFile();2930 // Adds the pages (specified by the page ranges) of the input PDF file to be inserted at the specified page of the base PDF file.31 insertPagesOperation.addPagesToInsertAt(firstFileToInsert, pageRanges, 2);3233 // Create a FileRef instance using a local file.34 FileRef secondFileToInsert = FileRef.createFromLocalFile("src/main/resources/secondFileToInsertInput.pdf");3536 // Adds all the pages of the input PDF file to be inserted at the specified page of the base PDF file.37 insertPagesOperation.addPagesToInsertAt(secondFileToInsert, 3);3839 // Execute the operation.40 FileRef result = insertPagesOperation.execute(executionContext);4142 // Save the result to the specified location.43 result.saveAs("output/insertPagesOutput.pdf");4445 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {46 LOGGER.error("Exception encountered while executing operation", e);47 }48 }4950 private static PageRanges getPageRangeForFirstFile() {51 // Specify which pages of the first file are to be inserted in the base file.52 PageRanges pageRanges = new PageRanges();53 // Add pages 1 to 3.54 pageRanges.addRange(1, 3);5556 // Add page 4.57 pageRanges.addSinglePage(4);5859 return pageRanges;60 }61}
Replace a page within a PDF file
Replace one or more pages with another page in an existing document
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Combine-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/combinepdf' \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 "assets": [10 {11 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",12 "pageRanges": [13 {14 "start": 1,15 "end": 116 }17 ]18 },19 {20 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",21 "pageRanges": [22 {23 "start": 224 }25 ]26 },27 {28 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",29 "pageRanges": [30 {31 "start": 332 }33 ]34 }35 ]36}'37// Legacy API can be found here38// https://documentcloud.adobe.com/document-services/index.html#post-combinePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/replacepages/replace-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getPageRangesForFirstFile = () => {8 // Specify pages of the first file for replacing the page of base PDF file.9 const pageRangesForFirstFile = new PDFServicesSdk.PageRanges();10 // Add pages 1 to 3.11 pageRangesForFirstFile.addPageRange(1, 3);1213 // Add page 4.14 pageRangesForFirstFile.addSinglePage(4);1516 return pageRangesForFirstFile;17};1819try {20 // Initial setup, create credentials instance.21 const credentials = PDFServicesSdk.Credentials22 .servicePrincipalCredentialsBuilder()23 .withClientId("PDF_SERVICES_CLIENT_ID")24 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")25 .build();2627 // Create an ExecutionContext using credentials and create a new operation instance.28 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),29 replacePagesOperation = PDFServicesSdk.ReplacePages.Operation.createNew();3031 // Set operation base input from a source file.32 const baseInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/baseInput.pdf');33 replacePagesOperation.setBaseInput(baseInputFile);3435 // Create a FileRef instance using a local file.36 const firstInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/replacePagesInput1.pdf'),37 pageRanges = getPageRangesForFirstFile();3839 // Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.40 replacePagesOperation.addPagesForReplace(1, firstInputFile, pageRanges);4142 // Create a FileRef instance using a local file.43 const secondInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/replacePagesInput2.pdf');4445 // Adds all the pages of the input PDF file for replacing the page of the base PDF file.46 replacePagesOperation.addPagesForReplace(3, secondInputFile);4748 // Execute the operation and Save the result to the specified location.49 replacePagesOperation.execute(executionContext)50 .then(result => result.saveAsFile('output/replacePagesOutput.pdf'))51 .catch(err => {52 if (err instanceof PDFServicesSdk.Error.ServiceApiError53 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {54 console.log('Exception encountered while executing operation', err);55 } else {56 console.log('Exception encountered while executing operation', err);57 }58 });59} catch (err) {60 console.log('Exception encountered while executing operation', err);61}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ReplacePDFPages/4// dotnet run ReplacePDFPages.csproj56namespace ReplacePDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 ReplacePagesOperation replacePagesOperation = ReplacePagesOperation.CreateNew();2829 // Set operation base input from a source file.30 FileRef baseSourceFile = FileRef.CreateFromLocalFile(@"baseInput.pdf");31 replacePagesOperation.SetBaseInput(baseSourceFile);3233 // Create a FileRef instance using a local file.34 FileRef firstInputFile = FileRef.CreateFromLocalFile(@"replacePagesInput1.pdf");35 PageRanges pageRanges = GetPageRangeForFirstFile();3637 // Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.38 replacePagesOperation.AddPagesForReplace(firstInputFile, pageRanges, 1);3940 // Create a FileRef instance using a local file.41 FileRef secondInputFile = FileRef.CreateFromLocalFile(@"replacePagesInput2.pdf");4243 // Adds all the pages of the input PDF file for replacing the page of the base PDF file.44 replacePagesOperation.AddPagesForReplace(secondInputFile, 3);4546 // Execute the operation.47 FileRef result = replacePagesOperation.Execute(executionContext);4849 // Save the result to the specified location.50 result.SaveAs(Directory.GetCurrentDirectory() + "/output/replacePagesOutput.pdf");51 }52 catch (ServiceUsageException ex)53 {54 log.Error("Exception encountered while executing operation", ex);55 // Catch more errors here . . .56 }5758 private static PageRanges GetPageRangeForFirstFile()59 {60 // Specify pages of the first file for replacing the page of base PDF file.61 PageRanges pageRanges = new PageRanges();62 // Add pages 1 to 3.63 pageRanges.AddRange(1, 3);6465 // Add page 4.66 pageRanges.AddSinglePage(4);6768 return pageRanges;69 }7071 static void ConfigureLogging()72 {73 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());74 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));75 }76 }77}
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.replacepages.ReplacePDFPages45public class ReplacePDFPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(ReplacePDFPages.class);910 public static void main(String[] args) {1112 try {13 // Initial setup, create credentials instance.14 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()15 .withClientId("PDF_SERVICES_CLIENT_ID")16 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")17 .build();1819 // Create an ExecutionContext using credentials and create a new operation instance.20 ExecutionContext executionContext = ExecutionContext.create(credentials);21 ReplacePagesOperation replacePagesOperation = ReplacePagesOperation.createNew();2223 // Set operation base input from a source file.24 FileRef baseSourceFile = FileRef.createFromLocalFile("src/main/resources/baseInput.pdf");25 replacePagesOperation.setBaseInput(baseSourceFile);2627 // Create a FileRef instance using a local file.28 FileRef firstInputFile = FileRef.createFromLocalFile("src/main/resources/replacePagesInput1.pdf");29 PageRanges pageRanges = getPageRangeForFirstFile();3031 // Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.32 replacePagesOperation.addPagesForReplace(firstInputFile, pageRanges, 1);333435 // Create a FileRef instance using a local file.36 FileRef secondInputFile = FileRef.createFromLocalFile("src/main/resources/replacePagesInput2.pdf");3738 // Adds all the pages of the input PDF file for replacing the page of the base PDF file.39 replacePagesOperation.addPagesForReplace(secondInputFile, 3);4041 // Execute the operation42 FileRef result = replacePagesOperation.execute(executionContext);4344 // Save the result at the specified location45 result.saveAs("output/replacePagesOutput.pdf");46 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {47 LOGGER.error("Exception encountered while executing operation", e);48 }49 }5051 private static PageRanges getPageRangeForFirstFile() {52 // Specify pages of the first file for replacing the page of base PDF file.53 PageRanges pageRanges = new PageRanges();54 // Add pages 1 to 3.55 pageRanges.addRange(1, 3);5657 // Add page 4.58 pageRanges.addSinglePage(4);5960 return pageRanges;61 }62}
Delete a page from a PDF file
Delete one or more pages from a document
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Page-Manipulation34curl --location --request POST 'https://pdf-services.adobe.io/operation/pagemanipulation' \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 "pageActions": [11 {12 "delete": {13 "pageRanges": [14 {15 "start": 1,16 "end": 217 }18 ]19 }20 }21 ]22}'2324// Legacy API can be found here25// https://documentcloud.adobe.com/document-services/index.html#post-pageManipulation
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/replacepages/replace-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getPageRangesForDeletion = () => {8 // Specify pages for deletion.9 const pageRangesForDeletion = new PDFServicesSdk.PageRanges();10 // Add page 1.11 pageRangesForDeletion.addSinglePage(1);1213 // Add pages 3 to 4.14 pageRangesForDeletion.addPageRange(3, 4);15 return pageRangesForDeletion;16};1718try {19 // Initial setup, create credentials instance.20 const credentials = PDFServicesSdk.Credentials21 .servicePrincipalCredentialsBuilder()22 .withClientId("PDF_SERVICES_CLIENT_ID")23 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")24 .build();2526 // Create an ExecutionContext using credentials and create a new operation instance.27 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),28 deletePagesOperation = PDFServicesSdk.DeletePages.Operation.createNew();2930 // Set operation input from a source file.31 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/deletePagesInput.pdf');32 deletePagesOperation.setInput(input);3334 // Delete pages of the document (as specified by PageRanges).35 const pageRangesForDeletion = getPageRangesForDeletion();36 deletePagesOperation.setPageRanges(pageRangesForDeletion);3738 // Execute the operation and Save the result to the specified location.39 deletePagesOperation.execute(executionContext)40 .then(result => result.saveAsFile('output/deletePagesOutput.pdf'))41 .catch(err => {42 if (err instanceof PDFServicesSdk.Error.ServiceApiError43 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {44 console.log('Exception encountered while executing operation', err);45 } else {46 console.log('Exception encountered while executing operation', err);47 }48 });49} catch (err) {50 console.log('Exception encountered while executing operation', err);51}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd DeletePDFPages/4// dotnet run DeletePDFPages.csproj56namespace DeletePDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 DeletePagesOperation deletePagesOperation = DeletePagesOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"deletePagesInput.pdf");31 deletePagesOperation.SetInput(sourceFileRef);3233 // Delete pages of the document (as specified by PageRanges).34 PageRanges pageRangeForDeletion = GetPageRangeForDeletion();35 deletePagesOperation.SetPageRanges(pageRangeForDeletion);3637 // Execute the operation.38 FileRef result = deletePagesOperation.Execute(executionContext);3940 // Save the result to the specified location.41 result.SaveAs(Directory.GetCurrentDirectory() + "/output/deletePagesOutput.pdf");42 }43 catch (ServiceUsageException ex)44 {45 log.Error("Exception encountered while executing operation", ex);46 }47 // Catch more errors here . . .48 }4950 private static PageRanges GetPageRangeForDeletion()51 {52 // Specify pages for deletion.53 PageRanges pageRangeForDeletion = new PageRanges();54 // Add page 1.55 pageRangeForDeletion.AddSinglePage(1);5657 // Add pages 3 to 4.58 pageRangeForDeletion.AddRange(3, 4);59 return pageRangeForDeletion;60 }6162 static void ConfigureLogging()63 {64 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());65 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));66 }67 }68}
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.deletepages.DeletePDFPages456public class DeletePDFPages {78// Initialize the logger.9private static final Logger LOGGER = LoggerFactory.getLogger(DeletePDFPages.class);1011public static void main(String[] args) {12 try {13 // Initial setup, create credentials instance.14 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()15 .withClientId("PDF_SERVICES_CLIENT_ID")16 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")17 .build();1819 // Create an ExecutionContext using credentials and create a new operation instance.20 ExecutionContext executionContext = ExecutionContext.create(credentials);21 DeletePagesOperation deletePagesOperation = DeletePagesOperation.createNew();2223 // Set operation input from a source file.24 FileRef source = FileRef.createFromLocalFile("src/main/resources/deletePagesInput.pdf");25 deletePagesOperation.setInput(source);2627 // Delete pages of the document (as specified by PageRanges).28 PageRanges pageRangeForDeletion = getPageRangeForDeletion();29 deletePagesOperation.setPageRanges(pageRangeForDeletion);3031 // Execute the operation.32 FileRef result = deletePagesOperation.execute(executionContext);3334 // Save the result to the specified location.35 result.saveAs("output/deletePagesOutput.pdf");3637 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {38 LOGGER.error("Exception encountered while executing operation", e);39 }40 }4142 private static PageRanges getPageRangeForDeletion() {43 // Specify pages for deletion.44 PageRanges pageRangeForDeletion = new PageRanges();45 // Add page 1.46 pageRangeForDeletion.addSinglePage(1);4748 // Add pages 3 to 4.49 pageRangeForDeletion.addRange(3, 4);50 return pageRangeForDeletion;51 }52}
Rotate a page in a PDF file
Rotate a page in an existing document.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Page-Manipulation34curl --location --request POST 'https://pdf-services.adobe.io/operation/pagemanipulation' \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-087832fca718f",10 "pageActions": [11 {12 "rotate": {13 "angle": 90,14 "pageRanges": [15 {16 "start": 117 }18 ]19 }20 },21 {22 "rotate": {23 "angle": 180,24 "pageRanges": [25 {26 "start": 2,27 "end": 228 }29 ]30 }31 }32 ]33}'3435// Legacy API can be found here36// https://documentcloud.adobe.com/document-services/index.html#post-pageManipulation
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/rotatepages/rotate-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getFirstPageRangeForRotation = () => {8 // Specify pages for rotation.9 const firstPageRange = new PDFServicesSdk.PageRanges();10 // Add page 1.11 firstPageRange.addSinglePage(1);1213 // Add pages 3 to 4.14 firstPageRange.addPageRange(3, 4);1516 return firstPageRange;17};1819const getSecondPageRangeForRotation = () => {20 // Specify pages for rotation.21 const secondPageRange = new PDFServicesSdk.PageRanges();22 // Add page 2.23 secondPageRange.addSinglePage(2);2425 return secondPageRange;26};2728try {29 // Initial setup, create credentials instance.30 const credentials = PDFServicesSdk.Credentials31 .servicePrincipalCredentialsBuilder()32 .withClientId("PDF_SERVICES_CLIENT_ID")33 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")34 .build();3536 // Create an ExecutionContext using credentials and create a new operation instance.37 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),38 rotatePagesOperation = PDFServicesSdk.RotatePages.Operation.createNew();3940 // Set operation input from a source file.41 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/rotatePagesInput.pdf');42 rotatePagesOperation.setInput(input);4344 // Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.45 const firstPageRange = getFirstPageRangeForRotation();46 rotatePagesOperation.setAngleToRotatePagesBy(PDFServicesSdk.RotatePages.Angle._90, firstPageRange);4748 // Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.49 const secondPageRange = getSecondPageRangeForRotation();50 rotatePagesOperation.setAngleToRotatePagesBy(PDFServicesSdk.RotatePages.Angle._180,secondPageRange);5152 // Execute the operation and Save the result to the specified location.53 rotatePagesOperation.execute(executionContext)54 .then(result => result.saveAsFile('output/rotatePagesOutput.pdf'))55 .catch(err => {56 if (err instanceof PDFServicesSdk.Error.ServiceApiError57 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {58 console.log('Exception encountered while executing operation', err);59 } else {60 console.log('Exception encountered while executing operation', err);61 }62 });63} catch (err) {64 console.log('Exception encountered while executing operation', err);65}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd RotatePDFPages/4// dotnet run RotatePDFPages.csproj56namespace RotatePDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 RotatePagesOperation rotatePagesOperation = RotatePagesOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"rotatePagesInput.pdf");31 rotatePagesOperation.SetInput(sourceFileRef);3233 // Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.34 PageRanges firstPageRange = GetFirstPageRangeForRotation();35 rotatePagesOperation.SetAngleToRotatePagesBy(Angle._90, firstPageRange);3637 // Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.38 PageRanges secondPageRange = GetSecondPageRangeForRotation();39 rotatePagesOperation.SetAngleToRotatePagesBy(Angle._180, secondPageRange);4041 // Execute the operation.42 FileRef result = rotatePagesOperation.Execute(executionContext);4344 // Save the result to the specified location.45 result.SaveAs(Directory.GetCurrentDirectory() + "/output/rotatePagesOutput.pdf");46 }47 catch (ServiceUsageException ex)48 {49 log.Error("Exception encountered while executing operation", ex);50 }51 // Catch more errors here . . .52 }5354 static void ConfigureLogging()55 {56 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());57 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));58 }5960 private static PageRanges GetFirstPageRangeForRotation()61 {62 // Specify pages for rotation.63 PageRanges firstPageRange = new PageRanges();64 // Add page 1.65 firstPageRange.AddSinglePage(1);6667 // Add pages 3 to 4.68 firstPageRange.AddRange(3, 4);69 return firstPageRange;70 }7172 private static PageRanges GetSecondPageRangeForRotation()73 {74 // Specify pages for rotation.75 PageRanges secondPageRange = new PageRanges();76 // Add page 2.77 secondPageRange.AddSinglePage(2);7879 return secondPageRange;80 }81 }82}
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.rotatepages.RotatePDFPages45public class RotatePDFPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(RotatePDFPages.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 RotatePagesOperation rotatePagesOperation = RotatePagesOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/rotatePagesInput.pdf");24 rotatePagesOperation.setInput(source);2526 // Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.27 PageRanges firstPageRange = getFirstPageRangeForRotation();28 rotatePagesOperation.setAngleToRotatePagesBy(Angle._90, firstPageRange);2930 // Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.31 PageRanges secondPageRange = getSecondPageRangeForRotation();32 rotatePagesOperation.setAngleToRotatePagesBy(Angle._180, secondPageRange);3334 // Execute the operation.35 FileRef result = rotatePagesOperation.execute(executionContext);3637 // Save the result to the specified location.38 result.saveAs("output/rotatePagesOutput.pdf");3940 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {41 LOGGER.error("Exception encountered while executing operation", e);42 }43 }4445 private static PageRanges getFirstPageRangeForRotation() {46 // Specify pages for rotation.47 PageRanges firstPageRange = new PageRanges();48 // Add page 1.49 firstPageRange.addSinglePage(1);5051 // Add pages 3 to 4.52 firstPageRange.addRange(3, 4);53 return firstPageRange;54 }5556 private static PageRanges getSecondPageRangeForRotation() {57 // Specify pages for rotation.58 PageRanges secondPageRange = new PageRanges();59 // Add page 2.60 secondPageRange.addSinglePage(2);6162 return secondPageRange;63 }64}
PDF content extraction
Extract text, images, tables, and more from native and scanned PDFs into a structured JSON file. PDF Extract API leverages AI technology to accurately identify text objects and understand the natural reading order of different elements such as headings, lists, and paragraphs spanning multiple columns or pages. Extract font styles with identification of metadata such as bold and italic text and their position within your PDF. Extracted content is output in a structured JSON file format with tables in CSV or XLSX and images saved as PNG.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Extract-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/extractpdf' \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 "elementsToExtract": [11 "text"12 ]13}'1415// Legacy API can be found here16// https://documentcloud.adobe.com/document-services/index.html#post-extractPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/extractpdf/extract-text-info-from-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');6try {7 // Initial setup, create credentials instance.8 const credentials = PDFServicesSdk.Credentials9 .servicePrincipalCredentialsBuilder()10 .withClientId("PDF_SERVICES_CLIENT_ID")11 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")12 .build();1314 // Create an ExecutionContext using credentials15 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1617 // Build extractPDF options18 const options = new PDFServicesSdk.ExtractPDF.options.ExtractPdfOptions.Builder()19 .addElementsToExtract(PDFServicesSdk.ExtractPDF.options.ExtractElementType.TEXT).build();2021 // Create a new operation instance.22 const extractPDFOperation = PDFServicesSdk.ExtractPDF.Operation.createNew(),23 input = PDFServicesSdk.FileRef.createFromLocalFile(24 'resources/extractPDFInput.pdf',25 PDFServicesSdk.ExtractPDF.SupportedSourceFormat.pdf26 );2728 // Set operation input from a source file.29 extractPDFOperation.setInput(input);3031 // Set options32 extractPDFOperation.setOptions(options);3334 extractPDFOperation.execute(executionContext)35 .then(result => result.saveAsFile('output/ExtractTextInfoFromPDF.zip'))36 .catch(err => {37 if(err instanceof PDFServicesSdk.Error.ServiceApiError38 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {39 console.log('Exception encountered while executing operation', err);40 } else {41 console.log('Exception encountered while executing operation', err);42 }43 });44} catch (err) {45 console.log('Exception encountered while executing operation', err);46}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ExtractTextInfoFromPDF/4// dotnet run ExtractTextInfoFromPDF.csproj56namespace ExtractTextInfoFromPDF7{8 class Program9 {10 private static readonly ILog log = LogManager.GetLogger(typeof(Program));11 static void Main()12 {13 // Configure the logging.14 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 ExtractPDFOperation extractPdfOperation = ExtractPDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"extractPDFInput.pdf");29 extractPdfOperation.SetInputFile(sourceFileRef);3031 // Build ExtractPDF options and set them into the operation.32 ExtractPDFOptions extractPdfOptions = ExtractPDFOptions.ExtractPDFOptionsBuilder()33 .AddElementsToExtract(new List<ExtractElementType>(new []{ ExtractElementType.TEXT}))34 .Build();35 extractPdfOperation .SetOptions(extractPdfOptions);3637 // Execute the operation.38 FileRef result = extractPdfOperation.Execute(executionContext);3940 // Save the result to the specified location.41 result.SaveAs(Directory.GetCurrentDirectory() + "/output/ExtractTextInfoFromPDF.zip");42 }43 catch (ServiceUsageException ex)44 {45 log.Error("Exception encountered while executing operation", ex);46 }47 catch (ServiceApiException ex)48 {49 log.Error("Exception encountered while executing operation", ex);50 }51 catch (SDKException ex)52 {53 log.Error("Exception encountered while executing operation", ex);54 }55 catch (IOException ex)56 {57 log.Error("Exception encountered while executing operation", ex);58 }59 catch (Exception ex)60 {61 log.Error("Exception encountered while executing operation", ex);62 }63 }6465 static void ConfigureLogging()66 {67 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());68 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));69 }70 }71}
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.extractpdf.ExtractTextInfoFromPDF45public class ExtractTextInfoFromPDF {67 private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ExtractTextInfoFromPDF.class);89 public static void main(String[] args) {1011 try {1213 // Initial setup, create credentials instance.14 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()15 .withClientId("PDF_SERVICES_CLIENT_ID")16 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")17 .build();1819 // Create an ExecutionContext using credentials.20 ExecutionContext executionContext = ExecutionContext.create(credentials);2122 ExtractPDFOperation extractPDFOperation = ExtractPDFOperation.createNew();2324 // Provide an input FileRef for the operation25 FileRef source = FileRef.createFromLocalFile("src/main/resources/extractPdfInput.pdf");26 extractPDFOperation.setInputFile(source);2728 // Build ExtractPDF options and set them into the operation29 ExtractPDFOptions extractPDFOptions = ExtractPDFOptions.extractPdfOptionsBuilder()30 .addElementsToExtract(Arrays.asList(ExtractElementType.TEXT))31 .build();32 extractPDFOperation.setOptions(extractPDFOptions);3334 // Execute the operation35 FileRef result = extractPDFOperation.execute(executionContext);3637 // Save the result at the specified location38 result.saveAs("output/ExtractTextInfoFromPDF.zip");3940 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException e) {41 LOGGER.error("Exception encountered while executing operation", e);42 }43 }44}
Copied to your clipboard1# Get the samples from http://www.adobe.com/go/pdftoolsapi_python_sample2# Run the sample:3# python src/extractpdf/extract_txt_from_pdf.py45logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))67try:8 #get base path.9 base_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))1011 #Initial setup, create credentials instance.12 credentials = Credentials.service_principal_credentials_builder()13 .with_client_id('PDF_SERVICES_CLIENT_ID')14 .with_client_secret('PDF_SERVICES_CLIENT_SECRET')15 .build()1617 #Create an ExecutionContext using credentials and create a new operation instance.18 execution_context = ExecutionContext.create(credentials)19 extract_pdf_operation = ExtractPDFOperation.create_new()2021 #Set operation input from a source file.22 source = FileRef.create_from_local_file(base_path + "/resources/extractPdfInput.pdf")23 extract_pdf_operation.set_input(source)2425 #Build ExtractPDF options and set them into the operation26 extract_pdf_options: ExtractPDFOptions = ExtractPDFOptions.builder() \27 .with_element_to_extract(ExtractElementType.TEXT) \28 .build()29 extract_pdf_operation.set_options(extract_pdf_options)3031 #Execute the operation.32 result: FileRef = extract_pdf_operation.execute(execution_context)3334 #Save the result to the specified location.35 result.save_as(base_path + "/output/ExtractTextInfoFromPDF.zip")36except (ServiceApiException, ServiceUsageException, SdkException):37 logging.exception("Exception encountered while executing operation")
Adobe PDF Accessibility Auto-Tag API
Tag PDFs to improve accessibility. Identify the content structure and reading order, and tag tables, paragraphs, lists, headings, figures, and more to improve the reading experience of native or scanned PDFs with assistive technologies. Generate a tailored tagging report about added tags and any content that needs additional review.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our REST API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/PDF-Accessibility-Auto-Tag34curl --location --request POST 'https://pdf-services.adobe.io/operation/autotag' \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}'
Copied to your clipboard1// Get the samples from https://github.com/adobe/pdfservices-node-sdk-samples2// Run the sample:3// node src/autotagpdf/autotag-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 autotagPDF = PDFServicesSdk.AutotagPDF,18 autotagPDFOperation = autotagPDF.Operation.createNew();1920 // Set operation input from a source file.21 const input = PDFServicesSdk.FileRef.createFromLocalFile('autotagPDFInput.pdf');22 autotagPDFOperation.setInput(input);2324 // Execute the operation and Save the result to the specified location.25 autotagPDFOperation.execute(executionContext)26 .then(result => {27 result.taggedPDF.saveAsFile('autotagPDFOutput.pdf');28 })29 .catch(err => {30 if(err instanceof PDFServicesSdk.Error.ServiceApiError31 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {32 console.log('Exception encountered while executing operation', err);33 } else {34 console.log('Exception encountered while executing operation', err);35 }36 });3738} catch (err) {39 console.log('Exception encountered while executing operation', err);40}
Copied to your clipboard1// Get the samples from https://github.com/adobe/PDFServices.NET.SDK.Samples2// Run the sample:3// cd AutotagPDF/4// dotnet run AutotagPDF.csproj56namespace AutotagPDF7{8 class Program9 {10 private static readonly ILog log = LogManager.GetLogger(typeof(Program));1112 static void Main()13 {14 //Configure the logging15 ConfigureLogging();16 try17 {18 // Initial setup, create credentials instance.19 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()20 .WithClientId("PDF_SERVICES_CLIENT_ID")21 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")22 .Build();2324 //Create an ExecutionContext using credentials and create a new operation instance.25 ExecutionContext executionContext = ExecutionContext.Create(credentials);26 AutotagPDFOperation autotagPDFOperation = AutotagPDFOperation.CreateNew();2728 // Provide an input FileRef for the operation29 autotagPDFOperation.SetInput(FileRef.CreateFromLocalFile(@"autotagPDFInput.pdf"));3031 // Execute the operation32 AutotagPDFOutput autotagPDFOutput = autotagPDFOperation.Execute(executionContext);3334 // Save the output files at the specified location35 autotagPDFOutput.GetTaggedPDF().SaveAs(Directory.GetCurrentDirectory() + "autotagPDFOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 catch (ServiceApiException ex)42 {43 log.Error("Exception encountered while executing operation", ex);44 }45 catch (SDKException ex)46 {47 log.Error("Exception encountered while executing operation", ex);48 }49 catch (IOException ex)50 {51 log.Error("Exception encountered while executing operation", ex);52 }53 catch (Exception ex)54 {55 log.Error("Exception encountered while executing operation", ex);56 }57 }5859 static void ConfigureLogging()60 {61 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());62 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));63 }64 }65}
Copied to your clipboard1// Get the samples from https://github.com/adobe/pdfservices-java-sdk-samples2// Run the sample:3// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.autotagpdf.AutotagPDF45public class AutotagPDF {6 // Initialize the logger.7 private static final Logger LOGGER = LoggerFactory.getLogger(AutotagPDF.class);89 public static void main(String[] args) {1011 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 AutotagPDFOperation autotagPDFOperation = AutotagPDFOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("autotagPDFInput.pdf");24 autotagPDFOperation.setInput(source);2526 // Execute the operation27 AutotagPDFOutput autotagPDFOutput = autotagPDFOperation.execute(executionContext);2829 // Save the tagged PDF output at the specified location30 autotagPDFOutput.getTaggedPDF().saveAs("autotagPDFOutput.pdf");3132 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {33 LOGGER.error("Exception encountered while executing operation", ex);34 }35 }36
Copied to your clipboard1# Get the samples from https://github.com/adobe/pdfservices-python-sdk-samples2# Run the sample:3# python src/autotagpdf/autotag_pdf.py45logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO'))67try:8 # get base path.9 base_path = str(Path(__file__).parents[2])1011 # Initial setup, create credentials instance.12 credentials = Credentials.service_principal_credentials_builder()13 .with_client_id('PDF_SERVICES_CLIENT_ID')14 .with_client_secret('PDF_SERVICES_CLIENT_SECRET')15 .build()1617 # Create an ExecutionContext using credentials and create a new operation instance.18 execution_context = ExecutionContext.create(credentials)19 autotag_pdf_operation = AutotagPDFOperation.create_new()2021 # Set operation input from a source file.22 input_file_path = 'autotagPdfInput.pdf'23 source = FileRef.create_from_local_file(base_path + '/resources/' + input_file_path)24 autotag_pdf_operation.set_input(source)2526 # Execute the operation.27 autotag_pdf_output: AutotagPDFOutput = autotag_pdf_operation.execute(execution_context)2829 input_file_name = Path(input_file_path).stem30 base_output_path = base_path + '/output/AutotagPDF/'3132 Path(base_output_path).mkdir(parents=True, exist_ok=True)33 tagged_pdf_path = f'{base_output_path}{input_file_name}-tagged.pdf'3435 # Save the result to the specified location.36 autotag_pdf_output.get_tagged_pdf().save_as(tagged_pdf_path)3738except (ServiceApiException, ServiceUsageException, SdkException) as e:39 logging.exception(f'Exception encountered while executing operation: {e}')
Create a PDF file
Create PDFs from a variety of formats, including static and dynamic HTML; Microsoft Word, PowerPoint, and Excel; as well as text, image, Zip, and URL. Support for HTML to PDF, DOC to PDF, DOCX to PDF, PPT to PDF, PPTX to PDF, XLS to PDF, XLSX to PDF, TXT to PDF, RTF to PDF, BMP to PDF, JPEG to PDF, GIF to PDF, TIFF to PDF, PNG to PDF
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Create-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/createpdf' \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}'1112// Legacy API can be found here13// https://documentcloud.adobe.com/document-services/index.html#post-createPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/createpdf/create-pdf-from-docx.js45const PDFservicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 createPdfOperation = PDFServicesSdk.CreatePDF.Operation.createNew();1819 // Set operation input from a source file.20 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/createPDFInput.docx');21 createPdfOperation.setInput(input);2223 // Execute the operation and Save the result to the specified location.24 createPdfOperation.execute(executionContext)25 .then(result => result.saveAsFile('output/createPDFFromDOCX.pdf'))26 .catch(err => {27 if(err instanceof PDFServicesSdk.Error.ServiceApiError28 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {29 console.log('Exception encountered while executing operation', err);30 } else {31 console.log('Exception encountered while executing operation', err);32 }33 });34} catch (err) {35 console.log('Exception encountered while executing operation', err);36}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd CreatePDFFromDocx/4// dotnet run CreatePDFFromDocx.csproj56namespace CreatePDFFromDocx7{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 CreatePDFOperation createPdfOperation = CreatePDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef source = FileRef.CreateFromLocalFile(@"createPdfInput.docx");29 createPdfOperation.SetInput(source);3031 // Execute the operation.32 FileRef result = createPdfOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/createPdfOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here. . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.createpdf.CreatePDFFromDOCX45public class CreatePDFFromDOCX {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(CreatePDFFromDOCX .class);910 public static void main(String[] args) {1112 try {1314 // Initial setup, create credentials instance.15 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()16 .withClientId("PDF_SERVICES_CLIENT_ID")17 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")18 .build();1920 //Create an ExecutionContext using credentials and create a new operation instance.21 ExecutionContext executionContext = ExecutionContext.create(credentials);22 CreatePDFOperation createPdfOperation = CreatePDFOperation.createNew();2324 // Set operation input from a source file.25 FileRef source = FileRef.createFromLocalFile("src/main/resources/createPDFInput.docx");26 createPdfOperation.setInput(source);2728 // Execute the operation.29 FileRef result = createPdfOperation.execute(executionContext);3031 // Save the result to the specified location.32 result.saveAs("output/createPDFFromDOCX.pdf");3334 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {35 LOGGER.error("Exception encountered while executing36 operation", ex);37 }38 }39}
Create a PDF file from HTML
Create PDFs from static and dynamic HTML, Zip, and URL.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Html-To-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/htmltopdf' \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 "json": "{}",11 "includeHeaderFooter": true,12 "pageLayout": {13 "pageWidth": 11,14 "pageHeight": 8.515 }16}'1718// Legacy API can be found here19// https://documentcloud.adobe.com/document-services/index.html#post-htmlToPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/createpdf/create-pdf-from-static-html.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const setCustomOptions = (htmlToPDFOperation) => {8 // Define the page layout, in this case an 8 x 11.5 inch page (effectively portrait orientation).9 const pageLayout = new PDFServicesSdk.CreatePDF.options.PageLayout();10 pageLayout.setPageSize(8, 11.5);1112 // Set the desired HTML-to-PDF conversion options.13 const htmlToPdfOptions = new PDFServicesSdk.CreatePDF.options.html.CreatePDFFromHtmlOptions.Builder()14 .includesHeaderFooter(true)15 .withPageLayout(pageLayout)16 .build();17 htmlToPDFOperation.setOptions(htmlToPdfOptions);18};192021try {22 // Initial setup, create credentials instance.23 const credentials = PDFServicesSdk.Credentials24 .servicePrincipalCredentialsBuilder()25 .withClientId("PDF_SERVICES_CLIENT_ID")26 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")27 .build();2829 // Create an ExecutionContext using credentials and create a new operation instance.30 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials), htmlToPDFOperation = PDFServicesSdk.CreatePDF.Operation.createNew();3132 // Set operation input from a source file.33 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/createPDFFromStaticHtmlInput.zip');34 htmlToPDFOperation.setInput(input);3536 // Provide any custom configuration options for the operation.37 setCustomOptions(htmlToPDFOperation);3839 // Execute the operation and Save the result to the specified location.40 htmlToPDFOperation.execute(executionContext)41 .then(result => result.saveAsFile('output/createPdfFromStaticHtmlOutput.pdf'))42 .catch(err => {43 if(err instanceof PDFServicesSdk.Error.ServiceApiError44 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {45 console.log('Exception encountered while executing operation', err);46 } else {47 console.log('Exception encountered while executing operation', err);48 }49 });50} catch (err) {51 console.log('Exception encountered while executing operation', err);52}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd CreatePDFFromStaticHtml/4// dotnet run CreatePDFFromStaticHtml.csproj56namespace CreatePDFFromStaticHtml7{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 CreatePDFOperation htmlToPDFOperation = CreatePDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef source = FileRef.CreateFromLocalFile(@"createPDFFromStaticHtmlInput.zip");29 htmlToPDFOperation.SetInput(source);3031 // Provide any custom configuration options for the operation.32 SetCustomOptions(htmlToPDFOperation);3334 // Execute the operation.35 FileRef result = htmlToPDFOperation.Execute(executionContext);3637 // Save the result to the specified location.38 result.SaveAs(Directory.GetCurrentDirectory() + "/output/createPdfFromStaticHtmlOutput.pdf");39 }40 catch (ServiceUsageException ex)41 {42 log.Error("Exception encountered while executing operation", ex);43 }44 // Catch more errors here. . .45 }4647 private static void SetCustomOptions(CreatePDFOperation htmlToPDFOperation)48 {49 // Define the page layout, in this case an 8 x 11.5 inch page (effectively portrait orientation).50 PageLayout pageLayout = new PageLayout();51 pageLayout.SetPageSize(8, 11.5);5253 // Set the desired HTML-to-PDF conversion options.54 CreatePDFOptions htmlToPdfOptions = CreatePDFOptions.HtmlOptionsBuilder()55 .IncludeHeaderFooter(true)56 .WithPageLayout(pageLayout)57 . Build();58 htmlToPDFOperation.SetOptions(htmlToPdfOptions);59 }6061 static void ConfigureLogging()62 {63 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());64 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));65 }66 }67}
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.createpdf.CreatePDFFromStaticHTML45public class CreatePDFFromStaticHTML {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(CreatePDFFromStaticHTML.class);910 public static void main(String[] args) {1112 try {1314 // Initial setup, create credentials instance.15 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()16 .withClientId("PDF_SERVICES_CLIENT_ID")17 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")18 .build();1920 //Create an ExecutionContext using credentials and create a new operation instance.21 ExecutionContext executionContext = ExecutionContext.create(credentials);22 CreatePDFOperation htmlToPDFOperation = CreatePDFOperation.createNew();2324 // Set operation input from a source file.25 FileRef source = FileRef.createFromLocalFile("src/main/resources/createPDFFromStaticHtmlInput.zip");26 htmlToPDFOperation.setInput(source);2728 // Provide any custom configuration options for the operation.29 setCustomOptions(htmlToPDFOperation);3031 // Execute the operation.32 FileRef result = htmlToPDFOperation.execute(executionContext);3334 // Save the result to the specified location.35 result.saveAs("output/createPDFFromStaticHtmlOutput.pdf");3637 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {38 LOGGER.error("Exception encountered while executing operation", ex);39 }40 }4142 private static void setCustomOptions(CreatePDFOperation htmlToPDFOperation) {43 // Define the page layout, in this case an 8 x 11.5 inch page (effectively portrait orientation).44 PageLayout pageLayout = new PageLayout();45 pageLayout.setPageSize(8, 11.5);4647 // Set the desired HTML-to-PDF conversion options.48 CreatePDFOptions htmlToPdfOptions = CreatePDFOptions.htmlOptionsBuilder()49 .includeHeaderFooter(true)50 .withPageLayout(pageLayout)51 .build();52 htmlToPDFOperation.setOptions(htmlToPdfOptions);53 }54}
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Document-Generation34curl --location --request POST 'https://pdf-services.adobe.io/operation/documentgeneration' \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 "outputFormat": "pdf",11 "jsonDataForMerge": {12 "customerName": "Kane Miller",13 "customerVisits": 100,14 "itemsBought": [15 {16 "name": "Sprays",17 "quantity": 50,18 "amount": 10019 },20 {21 "name": "Chemicals",22 "quantity": 100,23 "amount": 20024 }25 ],26 "totalAmount": 300,27 "previousBalance": 50,28 "lastThreeBillings": [29 100,30 200,31 30032 ],33 "photograph": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP88h8AAu0B9XNPCQQAAAAASUVORK5CYII="34 }35}'3637// Legacy API can be found here38// https://documentcloud.adobe.com/document-services/index.html#post-documentGeneration
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/documentmerge/merge-document-to-pdf.js45 const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Setup input data for the document merge process.16 const jsonString = "{\"customerName\": \"Kane Miller\", \"customerVisits\": 100}",17 jsonDataForMerge = JSON.parse(jsonString);1819 // Create an ExecutionContext using credentials.20 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);2122 // Create a new DocumentMerge options instance.23 const documentMerge = PDFServicesSdk.DocumentMerge,24 documentMergeOptions = documentMerge.options,25 options = new documentMergeOptions.DocumentMergeOptions(jsonDataForMerge, documentMergeOptions.OutputFormat.PDF);2627 // Create a new operation instance using the options instance.28 const documentMergeOperation = documentMerge.Operation.createNew(options);2930 // Set operation input document template from a source file.31 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/documentMergeTemplate.docx');32 documentMergeOperation.setInput(input);3334 // Execute the operation and Save the result to the specified location.35 documentMergeOperation.execute(executionContext)36 .then(result => result.saveAsFile('output/documentMergeOutput.pdf'))37 .catch(err => {38 if(err instanceof PDFServicesSdk.Error.ServiceApiError39 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {40 console.log('Exception encountered while executing operation', err);41 } else {42 console.log('Exception encountered while executing operation', err);43 }44 });45}46catch (err) {47 console.log('Exception encountered while executing operation', err);48}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd MergeDocumentToPDF/4// dotnet run MergeDocumentToPDF.csproj56namespace MergeDocumentToPDF7{8 class Program9 {10 private static readonly ILog log = LogManager.GetLogger(typeof(Program));1112 static void Main()13 {14 //Configure the logging.15 ConfigureLogging();16 try17 {18 // Initial setup, create credentials instance.19 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()20 .WithClientId("PDF_SERVICES_CLIENT_ID")21 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")22 .Build();2324 // Create an ExecutionContext using credentials.25 ExecutionContext executionContext = ExecutionContext.Create(credentials);2627 // Setup input data for the document merge process.28 JObject jsonDataForMerge = JObject.Parse("{\"customerName\": \"Kane Miller\",\"customerVisits\": 100}");2930 // Create a new DocumentMerge Options instance.31 DocumentMergeOptions documentMergeOptions = new DocumentMergeOptions(jsonDataForMerge, OutputFormat.PDF);3233 // Create a new DocumentMerge Operation instance with the DocumentMerge Options instance.34 DocumentMergeOperation documentMergeOperation = DocumentMergeOperation.CreateNew(documentMergeOptions);3536 // Set the operation input document template from a source file.37 documentMergeOperation.SetInput(FileRef.CreateFromLocalFile(@"documentMergeTemplate.docx"));3839 // Execute the operation.40 FileRef result = documentMergeOperation.Execute(executionContext);4142 // Save the result to the specified location.43 result.SaveAs(Directory.GetCurrentDirectory() + "/output/documentMergeOutput.pdf");44 }45 catch (ServiceUsageException ex)46 {47 log.Error("Exception encountered while executing operation", ex);48 }49 catch (ServiceApiException ex)50 {51 log.Error("Exception encountered while executing operation", ex);52 }53 catch (SDKException ex)54 {55 log.Error("Exception encountered while executing operation", ex);56 }57 catch (IOException ex)58 {59 log.Error("Exception encountered while executing operation", ex);60 }61 catch (Exception ex)62 {63 log.Error("Exception encountered while executing operation", ex);64 }65 }6667 static void ConfigureLogging()68 {69 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());70 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));71 }72 }73}
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.documentmerge.MergeDocumentToPDF45package com.adobe.pdfservices.operation.samples.documentmerge;67public class MergeDocumentToPDF {89 // Initialize the logger.10 private static final Logger LOGGER = LoggerFactory.getLogger(MergeDocumentToPDF.class);1112 public static void main(String[] args) {1314 try {1516 // Initial setup, create credentials instance.17 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()18 .withClientId("PDF_SERVICES_CLIENT_ID")19 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")20 .build();2122 // Setup input data for the document merge process.23 JSONObject jsonDataForMerge = new JSONObject("{\"customerName\": \"Kane Miller\",\"customerVisits\": 100}");2425 // Create an ExecutionContext using credentials.26 ExecutionContext executionContext = ExecutionContext.create(credentials);2728 // Create a new DocumentMergeOptions instance.29 DocumentMergeOptions documentMergeOptions = new DocumentMergeOptions(jsonDataForMerge, OutputFormat.PDF);3031 // Create a new DocumentMergeOperation instance with the DocumentMergeOptions instance.32 DocumentMergeOperation documentMergeOperation = DocumentMergeOperation.createNew(documentMergeOptions);3334 // Set the operation input document template from a source file.35 FileRef documentTemplate = FileRef.createFromLocalFile("src/main/resources/documentMergeTemplate.docx");36 documentMergeOperation.setInput(documentTemplate);3738 // Execute the operation.39 FileRef result = documentMergeOperation.execute(executionContext);4041 // Save the result to the specified location.42 result.saveAs("output/documentMergeOutput.pdf");4344 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {45 LOGGER.error("Exception encountered while executing operation", ex);46 }47 }48}
PDF Electronic Seal API
Apply an electronic seal to documents at scale using a certificate issued by certain TSPs (Trust Service Providers) on Adobe’s Approved Trust List (AATL). The electronic seal helps verify the identity and integrity of documents.
See our public API Reference and quickly try our APIs using the Postman collections.
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer-stage.adobe.com/document-services/docs/apis/#tag/PDF-Electronic-Seal34curl --location --request POST 'https://pdf-services.adobe.io/operation/electronicseal' \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 "inputDocumentAssetID": "urn:aaid:AS:UE1:23c30ee0-2c4d-xxxx-xxxx-087832fca718",10 "sealImageAssetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-xxxx-xxxx-087832fca718",11 "sealOptions": {12 "signatureFormat": "PKCS7",13 "cscCredentialOptions": {14 "credentialId": "<CREDENTIAL_ID>",15 "providerName": "<PROVIDER_NAME>",16 "authorizationContext": {17 "tokenType": "Bearer",18 "accessToken": "<ACCESS_TOKEN>"19 },20 "credentialAuthParameters": {21 "pin": "<PIN>"22 }23 },24 "sealFieldOptions": {25 "location": {26 "top": 300,27 "left": 50,28 "right": 250,29 "bottom": 10030 },31 "fieldName": "Signature1",32 "pageNumber": 133 },34 "sealAppearanceOptions": {35 "displayOptions": [36 "NAME",37 "DATE",38 "DISTINGUISHED_NAME",39 "LABELS",40 "SEAL_IMAGE"41 ]42 }43 }44}'
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/electronicseal/electronic-seal.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');6try {7 // Initial setup, create credentials instance.8 const credentials = PDFServicesSdk.Credentials9 .servicePrincipalCredentialsBuilder()10 .withClientId("PDF_SERVICES_CLIENT_ID")11 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")12 .build();1314 // Create an ExecutionContext using credentials15 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1617 const pdfElectronicSeal = PDFServicesSdk.PDFElectronicSeal,18 options = pdfElectronicSeal.options;1920 //Get the input document to perform the sealing operation21 const sourceFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/sampleInvoice.pdf'),2223 //Get the background seal image for signature , if required.24 sealImageFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/sampleSealImage.png');2526 // Set the Seal Field Name to be created in input PDF document.27 sealFieldName = "Signature1";2829 // Set the page number in input document for applying seal.30 sealPageNumber = 1;3132 // Set if seal should be visible or invisible.33 sealVisible = true;3435 //Create FieldLocation instance and set the coordinates for applying signature36 fieldLocation = new options.FieldLocation(150,250,350,200);3738 //Create FieldOptions instance with required details.39 fieldOptions = new options.FieldOptions.Builder(sealFieldName)40 .setFieldLocation(fieldLocation)41 .setPageNumber(sealPageNumber)42 .setVisible(sealVisible)43 .build();4445 //Set the name of TSP Provider being used.46 providerName = "<PROVIDER_NAME>";4748 //Set the access token to be used to access TSP provider hosted APIs.49 accessToken = "<ACCESS_TOKEN>";5051 //Set the credential ID.52 credentialID = "<CREDENTIAL_ID>";5354 //Set the PIN generated while creating credentials.55 pin = "<PIN>";5657 //Create CSCAuthContext instance using access token and token type.58 cscAuthContext = new options.CSCAuthContext(accessToken, "Bearer");5960 //Create CertificateCredentials instance with required certificate details.61 certificateCredentials = options.CertificateCredentials.cscCredentialBuilder()62 .withProviderName(providerName)63 .withCredentialID(credentialID)64 .withPin(pin)65 .withCSCAuthContext(cscAuthContext)66 .build();6768 //Create SealOptions instance with sealing parameters.69 sealOptions = new options.SealOptions.Builder(certificateCredentials, fieldOptions)70 .build()7172 //Create the PDFElectronicSealOperation instance using the SealOptions instance73 const pdfElectronicSealOperation = pdfElectronicSeal.Operation.createNew(sealOptions);7475 //Set the input source file for PDFElectronicSealOperation instance76 pdfElectronicSealOperation.setInput(sourceFile);7778 //Set the optional input seal image for PDFElectronicSealOperation instance79 pdfElectronicSealOperation.setSealImage(sealImageFile);8081 // Execute the operation and Save the result to the specified location.82 pdfElectronicSealOperation.execute(executionContext)83 .then(result => result.saveAsFile("output/ElectronicSeal/sealedOutput.pdf"))84 .catch(err => {85 if(err instanceof PDFServicesSdk.Error.ServiceApiError86 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {87 console.log('Exception encountered while executing operation', err);88 } else {89 console.log('Exception encountered while executing operation', err);90 }91 });
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ElectronicSeal/4// dotnet run ElectronicSeal.csproj56namespace ElectronicSeal7{8 class Program9 {10 // Initialize the logger.11 private static readonly ILog log = LogManager.GetLogger(typeof(Program));12 static void Main()13 {14 //Configure the logging15 ConfigureLogging();1617 try18 {19 // Initial setup, create credentials instance.20 Credentials credentials = Credentials.ServicePrincipalCredentialsBuilder()21 .WithClientId("PDF_SERVICES_CLIENT_ID")22 .WithClientSecret("PDF_SERVICES_CLIENT_SECRET")23 .Build();2425 // Create an ExecutionContext using credentials.26 ExecutionContext executionContext = ExecutionContext.Create(credentials);2728 //Set the input document to perform the sealing operation29 FileRef sourceFile = FileRef.CreateFromLocalFile(@"SampleInvoice.pdf");3031 //Set the background seal image for signature , if required.32 FileRef sealImageFile = FileRef.CreateFromLocalFile(@"sampleSealImage.png");3334 //Set the Seal Field Name to be created in input PDF document.35 string sealFieldName = "Signature1";3637 //Set the page number in input document for applying seal.38 int sealPageNumber = 1;3940 //Set if seal should be visible or invisible.41 bool sealVisible = true;4243 //Create FieldLocation instance and set the coordinates for applying signature44 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);4546 //Create FieldOptions instance with required details.47 FieldOptions sealFieldOptions = new FieldOptions.Builder(sealFieldName)48 .SetVisible(sealVisible)49 .SetFieldLocation(fieldLocation)50 .SetPageNumber(sealPageNumber)51 .Build();5253 //Set the name of TSP Provider being used.54 string providerName = "<PROVIDER_NAME>";5556 //Set the access token to be used to access TSP provider hosted APIs.57 string accessToken = "<ACCESS_TOKEN>";5859 //Set the credential ID.60 string credentialID = "<CREDENTIAL_ID>";6162 //Set the PIN generated while creating credentials.63 string pin = "<PIN>";6465 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");6667 //Create CertificateCredentials instance with required certificate details.68 CertificateCredentials certificateCredentials = CertificateCredentials.CSCCredentialBuilder()69 .WithProviderName(providerName)70 .WithCredentialID(credentialID)71 .WithPin(pin)72 .WithCSCAuthContext(cscAuthContext)73 .Build();7475 //Create SealingOptions instance with all the sealing parameters.76 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, sealFieldOptions).Build();7778 //Create the PDFElectronicSealOperation instance using the PDFElectronicSealOptions instance79 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.CreateNew(sealOptions);8081 //Set the input source file for PDFElectronicSealOperation instance82 pdfElectronicSealOperation.SetInput(sourceFile);8384 //Set the optional input seal image for PDFElectronicSealOperation instance85 pdfElectronicSealOperation.SetSealImage(sealImageFile);8687 //Execute the operation88 FileRef result = pdfElectronicSealOperation.Execute(executionContext);8990 // Save the result to the specified location.91 result.SaveAs("/output/sealedOutput");92 }93 catch (ServiceUsageException ex)94 {95 log.Error("Exception encountered while executing operation", ex);96 }97 catch (ServiceApiException ex)98 {99 log.Error("Exception encountered while executing operation", ex);100 }101 catch (SDKException ex)102 {103 log.Error("Exception encountered while executing operation", ex);104 }105 catch (IOException ex)106 {107 log.Error("Exception encountered while executing operation", ex);108 }109 catch (Exception ex)110 {111 log.Error("Exception encountered while executing operation", ex);112 }113114 }115 static void ConfigureLogging()116 {117 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());118 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));119 }
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.electronicseal.ElectronicSeal45public class ElectronicSeal {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(ElectronicSeal.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials.19 ExecutionContext executionContext = ExecutionContext.create(credentials);2021 //Get the input document to perform the sealing operation22 FileRef sourceFile = FileRef.createFromLocalFile("src/main/resources/sampleInvoice.pdf");2324 //Get the background seal image for signature , if required.25 FileRef sealImageFile = FileRef.createFromLocalFile("src/main/resources/sampleSealImage.png");2627 //Set the Seal Field Name to be created in input PDF document.28 String sealFieldName = "Signature1";2930 //Set the page number in input document for applying seal.31 Integer sealPageNumber = 1;3233 //Set if seal should be visible or invisible.34 Boolean sealVisible = true;3536 //Create FieldLocation instance and set the coordinates for applying signature37 FieldLocation fieldLocation = new FieldLocation(150, 250, 350, 200);3839 //Create FieldOptions instance with required details.40 FieldOptions fieldOptions = new FieldOptions.Builder(sealFieldName)41 .setFieldLocation(fieldLocation)42 .setPageNumber(sealPageNumber)43 .setVisible(sealVisible)44 .build();4546 //Set the name of TSP Provider being used.47 String providerName = "<PROVIDER_NAME>";4849 //Set the access token to be used to access TSP provider hosted APIs.50 String accessToken = "<ACCESS_TOKEN>";5152 //Set the credential ID.53 String credentialID = "<CREDENTIAL_ID>";5455 //Set the PIN generated while creating credentials.56 String pin = "<PIN>";5758 //Create CSCAuthContext instance using access token and token type.59 CSCAuthContext cscAuthContext = new CSCAuthContext(accessToken, "Bearer");6061 //Create CertificateCredentials instance with required certificate details.62 CertificateCredentials certificateCredentials = CertificateCredentials.cscCredentialBuilder()63 .withProviderName(providerName)64 .withCredentialID(credentialID)65 .withPin(pin)66 .withCSCAuthContext(cscAuthContext)67 .build();6869 //Create SealOptions instance with sealing parameters.70 SealOptions sealOptions = new SealOptions.Builder(certificateCredentials, fieldOptions).build();7172 //Create the PDFElectronicSealOperation instance using the SealOptions instance73 PDFElectronicSealOperation pdfElectronicSealOperation = PDFElectronicSealOperation.createNew(sealOptions);7475 //Set the input source file for PDFElectronicSealOperation instance76 pdfElectronicSealOperation.setInput(sourceFile);7778 //Set the optional input seal image for PDFElectronicSealOperation instance79 pdfElectronicSealOperation.setSealImage(sealImageFile);8081 //Execute the operation82 FileRef result = pdfElectronicSealOperation.execute(executionContext);8384 //Save the output at specified location85 result.saveAs("output/ElectronicSeal/sealedOutput.pdf");868788 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {89 LOGGER.error("Exception encountered while executing operation", ex);90 }91 }
Convert a PDF file to other formats
Convert existing PDFs to popular formats, such as Microsoft Word, Excel, and PowerPoint, as well as text and image
Support for PDF to DOC, PDF to DOCX, PDF to JPEG, PDF to PNG, PDF to PPTX, PDF to RTF, PDF to XLSX
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Export-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/exportpdf' \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 "targetFormat": "docx"11}'1213// Legacy API can be found here14// https://documentcloud.adobe.com/document-services/index.html#post-exportPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/exportpdf/export-pdf-to-docx.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 //Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 exportPDF = PDFServicesSdk.ExportPDF,18 exportPdfOperation = exportPDF.Operation.createNew(exportPDF.SupportedTargetFormats.DOCX);1920 // Set operation input from a source file21 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/exportPDFInput.pdf');22 exportPdfOperation.setInput(input);2324 // Execute the operation and Save the result to the specified location.25 exportPdfOperation.execute(executionContext)26 .then(result => result.saveAsFile('output/exportPdfOutput.docx'))27 .catch(err => {28 if(err instanceof PDFServicesSdk.Error.ServiceApiError29 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {30 console.log('Exception encountered while executing operation', err);31 } else {32 console.log('Exception encountered while executing operation', err);33 }34 });35} catch (err) {36 console.log('Exception encountered while executing operation', err);37}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ExportPDFToDocx/4// dotnet run ExportPDFToDocx.csproj56 namespace ExportPDFToDocx7{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 ExportPDFOperation exportPdfOperation = ExportPDFOperation.CreateNew(ExportPDFTargetFormat.DOCX);2627 // Set operation input from a local PDF file28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"exportPdfInput.pdf");29 exportPdfOperation.SetInput(sourceFileRef);3031 // Execute the operation.32 FileRef result = exportPdfOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/exportPdfOutput.docx");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here. . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.exportpdf.ExportPDFToDOCX45public class ExportPDFToDOCX {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(ExportPDFToDOCX.class);910 public static void main(String[] args) {1112 try {13 // Initial setup, create credentials instance.14 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()15 .withClientId("PDF_SERVICES_CLIENT_ID")16 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")17 .build();18 //Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 ExportPDFOperation exportPdfOperation = ExportPDFOperation.createNew(ExportPDFTargetFormat.DOCX);2122 // Set operation input from a local PDF file23 FileRef sourceFileRef = FileRef.createFromLocalFile("src/main/resources/exportPDFInput.pdf");24 exportPdfOperation.setInput(sourceFileRef);2526 // Execute the operation.27 FileRef result = exportPdfOperation.execute(executionContext);2829 // Save the result to the specified location.30 result.saveAs("output/exportPdfOutput.docx");3132 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {33 LOGGER.error("Exception encountered while executing operation", ex);34 }35 }36}
OCR a PDF file
Use built-in optical character recognition (OCR) to convert images to text and enable fully text searchable documents for archiving and creation of searchable indexes.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Ocr34curl --location --request POST 'https://pdf-services.adobe.io/operation/ocr' \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}'1112// Legacy API can be found here13// https://documentcloud.adobe.com/document-services/index.html#post-ocr
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/ocr/ocr-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 ocrOperation = PDFServicesSdk.OCR.Operation.createNew();1819 // Set operation input from a source file.20 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/ocrInput.pdf');21 ocrOperation.setInput(input);2223 // Execute the operation and Save the result to the specified location.24 ocrOperation.execute(executionContext)25 .then(result => result.saveAsFile('output/ocrOutput.pdf'))26 .catch(err => {27 if(err instanceof PDFServicesSdk.Error.ServiceApiError28 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {29 console.log('Exception encountered while executing operation', err);30 } else {31 console.log('Exception encountered while executing operation', err);32 }33 });34} catch (err) {35 console.log('Exception encountered while executing operation', err);36}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd OcrPDF/4// dotnet run OcrPDF.csproj56namespace OcrPDF7{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 OCROperation ocrOperation = OCROperation.CreateNew();2627 // Set operation input from a source file.28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"ocrInput.pdf");29 ocrOperation.SetInput(sourceFileRef);3031 // Execute the operation.32 FileRef result = ocrOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/ocrOperationOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here. . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.ocrpdf.OcrPDF45public class OcrPDF {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(OcrPDF.class);910 public static void main(String[] args) {1112 try {1314 // Initial setup, create credentials instance.15 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()16 .withClientId("PDF_SERVICES_CLIENT_ID")17 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")18 .build();1920 //Create an ExecutionContext using credentials and create a new operation instance.21 ExecutionContext executionContext = ExecutionContext.create(credentials);22 OCROperation ocrOperation = OCROperation.createNew();2324 // Set operation input from a source file.25 FileRef source = FileRef.createFromLocalFile("src/main/resources/ocrInput.pdf");26 ocrOperation.setInput(source);2728 // Execute the operation29 FileRef result = ocrOperation.execute(executionContext);3031 // Save the result at the specified location32 result.saveAs("output/ocrOutput.pdf");3334 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {35 LOGGER.error("Exception encountered while executing operation", ex);36 }37 }38}
Secure a PDf file and set restrictions
Secure a PDF file with a password encrypt the document. Set an owner password and restrictions on certain features like printing, editing and copying in the PDF document to prevent end users from modifying it.
Support for AES-128 and AES-256 encryption on PDF files, with granular permissions for high and low quality printing and fill and sign form field restrictions.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Protect-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/protectpdf' \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 "passwordProtection": {10 "userPassword": "user_password"11 },12 "encryptionAlgorithm": "AES_128",13 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718"14}'1516// Legacy API can be found here17// https://documentcloud.adobe.com/document-services/index.html#post-protectPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/protectpdf/protect-pdf.js45 const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67 try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 // Build ProtectPDF options by setting a User Password and Encryption Algorithm (used for encrypting the PDF file).19 const protectPDF = PDFServicesSdk.ProtectPDF,20 options = new protectPDF.options.PasswordProtectOptions.Builder()21 .setUserPassword("encryptPassword")22 .setEncryptionAlgorithm(PDFServicesSdk.ProtectPDF.options.EncryptionAlgorithm.AES_256)23 .build();2425 // Create a new operation instance.26 const protectPDFOperation = protectPDF.Operation.createNew(options);2728 // Set operation input from a source file.29 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/protectPDFInput.pdf');30 protectPDFOperation.setInput(input);3132 // Execute the operation and Save the result to the specified location.33 protectPDFOperation.execute(executionContext)34 .then(result => result.saveAsFile('output/protectPDFOutput.pdf'))35 .catch(err => {36 if(err instanceof PDFServicesSdk.Error.ServiceApiError37 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {38 console.log('Exception encountered while executing operation', err);39 } else {40 console.log('Exception encountered while executing operation', err);41 }42 });43 } catch (err) {44 console.log('Exception encountered while executing operation', err);45}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ProtectPDF/4// dotnet run ProtectPDF.csproj56namespace ProtectPDF7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Build ProtectPDF options by setting a User Password and Encryption Algorithm (used for encrypting the PDF file).27 ProtectPDFOptions protectPDFOptions = ProtectPDFOptions.PasswordProtectOptionsBuilder()28 .SetUserPassword("encryptPassword")29 .SetEncryptionAlgorithm(EncryptionAlgorithm.AES_256)30 .Build();3132 // Create a new operation instance33 ProtectPDFOperation protectPDFOperation = ProtectPDFOperation.CreateNew(protectPDFOptions);3435 // Set operation input from a source file.36 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"protectPDFInput.pdf");37 protectPDFOperation.SetInput(sourceFileRef);3839 // Execute the operation.40 FileRef result = protectPDFOperation.Execute(executionContext);4142 // Save the result to the specified location.43 result.SaveAs(Directory.GetCurrentDirectory() + "/output/protectPDFOutput.pdf");44 }45 catch (ServiceUsageException ex)46 {47 log.Error("Exception encountered while executing operation", ex);48 }49 // Catch more errors here . . .50 }5152 static void ConfigureLogging()53 {54 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());55 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));56 }57 }58}
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.protectpdf.ProtectPDF45public class ProtectPDF {6 // Initialize the logger.7 private static final Logger LOGGER = LoggerFactory.getLogger(ProtectPDF.class);89 public static void main(String[] args) {1011 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials.19 ExecutionContext executionContext = ExecutionContext.create(credentials);2021 // Build ProtectPDF options by setting a User Password and Encryption Algorithm (used for encrypting the PDF file).22 ProtectPDFOptions protectPDFOptions = ProtectPDFOptions.passwordProtectOptionsBuilder()23 .setUserPassword("encryptPassword")24 .setEncryptionAlgorithm(EncryptionAlgorithm.AES_256)25 .build();2627 // Create a new operation instance.28 ProtectPDFOperation protectPDFOperation = ProtectPDFOperation.createNew(protectPDFOptions);2930 // Set operation input from a source file.31 FileRef source = FileRef.createFromLocalFile("src/main/resources/protectPDFInput.pdf");32 protectPDFOperation.setInput(source);3334 // Execute the operation35 FileRef result = protectPDFOperation.execute(executionContext);3637 // Save the result at the specified location38 result.saveAs("output/protectPDFOutput.pdf");3940 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {41 LOGGER.error("Exception encountered while executing operation", ex);42 }43 }44}
Remove the password from a PDF file
Remove password security from a PDF document. This can only be accomplished with the owner password of the document which must be passed in the operation.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Remove-Protection34curl --location --request POST 'https://pdf-services.adobe.io/operation/removeprotection' \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 "password": "mypassword",10 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718"11}'1213// Legacy API can be found here14// https://documentcloud.adobe.com/document-services/index.html#post-removeProtection
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/removeprotection/remove-protection.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 // Create a new operation instance.19 const removeProtectionOperation = PDFServicesSdk.RemoveProtection.Operation.createNew(),20 input = PDFServicesSdk.FileRef.createFromLocalFile(21 'resources/removeProtectionInput.pdf',22 PDFServicesSdk.RemoveProtection.SupportedSourceFormat.pdf23 );24 // Set operation input from a source file.25 removeProtectionOperation.setInput(input);2627 // Set the password for removing security from a PDF document.28 removeProtectionOperation.setPassword("password");2930 // Execute the operation and Save the result to the specified location.31 removeProtectionOperation.execute(executionContext)32 .then(result => result.saveAsFile('output/removeProtectionOutput.pdf'))33 .catch(err => {34 if(err instanceof PDFServicesSdk.Error.ServiceApiError35 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {36 console.log('Exception encountered while executing operation', err);37 } else {38 console.log('Exception encountered while executing operation', err);39 }40 });41} catch (err) {42 console.log('Exception encountered while executing operation', err);43}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd RemoveProtection/4// dotnet run RemoveProtection.csproj56namespace RemoveProtection7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"removeProtectionInput.pdf");31 removeProtectionOperation.SetInput(sourceFileRef);3233 // Set the password for removing security from a PDF document.34 removeProtectionOperation.SetPassword("password");3536 // Execute the operation.37 FileRef result = removeProtectionOperation.Execute(executionContext);3839 // Save the result to the specified location.40 result.SaveAs(Directory.GetCurrentDirectory() + "/output/removeProtectionOutput.pdf");41 }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 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.removeprotection.RemoveProtection45public class RemoveProtection {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(RemoveProtection.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 RemoveProtectionOperation removeProtectionOperation = RemoveProtectionOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/removeProtectionInput.pdf");24 removeProtectionOperation.setInput(source);2526 // Set the password for removing security from a PDF document.27 removeProtectionOperation.setPassword("password");2829 // Execute the operation.30 FileRef result = removeProtectionOperation.execute(executionContext);3132 // Save the result to the specified location.33 result.saveAs("output/removeProtectionOutput.pdf");3435 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {36 LOGGER.error("Exception encountered while executing operation", e);37 }38 }39}
Get the properties of a PDF file
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.
See our public API Reference and quickly try our APIs using the Postman collections
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}'1213// Legacy API can be found here14// https://documentcloud.adobe.com/document-services/index.html#post-pdfProperties
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/exportpdf/get-pdf-properties.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 //Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 pdfPropertiesOperation = PDFServicesSdk.PDFProperties.Operation.createNew();1819 // Set operation input from a source file.20 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/pdfPropertiesInput.pdf');21 pdfPropertiesOperation.setInput(input);2223 // Provide any custom configuration options for the operation.24 const options = new PDFServicesSdk.PDFProperties.options.PDFPropertiesOptions.Builder()25 .includePageLevelProperties(true)26 .build();27 pdfPropertiesOperation.setOptions(options);2829 // Execute the operation ang get properties of the PDF in PDFProperties object.30 pdfPropertiesOperation.execute(executionContext)31 .then(result => console.log("The resultant json object is : " + JSON.stringify(result, null, 4)))32 .catch(err => {33 if(err instanceof PDFServicesSdk.Error.ServiceApiError34 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {35 console.log('Exception encountered while executing operation', err);36 } else {37 console.log('Exception encountered while executing operation', err);38 }39 });40} catch (err) {41 console.log('Exception encountered while executing operation', err);42}
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 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.GetPDFProperties45public 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 {1314 // Initial setup, create credentials instance.15 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()16 .withClientId("PDF_SERVICES_CLIENT_ID")17 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")18 .build();1920 //Create an ExecutionContext using credentials and create a new operation instance.21 ExecutionContext executionContext = ExecutionContext.create(credentials);22 PDFPropertiesOperation pdfPropertiesOperation = PDFPropertiesOperation.createNew();2324 // Provide an input FileRef for the operation25 FileRef source = FileRef.createFromLocalFile("src/main/resources/pdfPropertiesInput.pdf");26 pdfPropertiesOperation.setInputFile(source);2728 // Build PDF Properties options to include page level properties and set them into the operation29 PDFPropertiesOptions pdfPropertiesOptions = PDFPropertiesOptions.PDFPropertiesOptionsBuilder()30 .includePageLevelProperties(true)31 .build();32 pdfPropertiesOperation.setOptions(pdfPropertiesOptions);3334 // Execute the operation ang get properties of the PDF in PDFProperties object.35 PDFProperties result = pdfPropertiesOperation.execute(executionContext);3637 // Get properties of the PDF38 LOGGER.info("The Page level properties of the PDF: {}", result.getDocument().getPageCount());39 LOGGER.info("The Fonts used in the PDF: ");40 for(Font font: result.getDocument().getFonts()) {41 LOGGER.info(font.getName());42 }4344 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {45 LOGGER.error("Exception encountered while executing operation", ex);46 }47 }48}
Split a PDF into multiple files
Split a PDF document into multiple smaller documents by simply specifying either the number of files, pages per file, or page ranges.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Split-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/splitpdf' \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 "splitoption": {11 "pageCount": 912 }13}'1415// Legacy API can be found here16// https://documentcloud.adobe.com/document-services/index.html#post-splitPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/splitpdf/split-pdf-by-number-of-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials);1718 // Create a new operation instance.19 const splitPDFOperation = PDFServicesSdk.SplitPDF.Operation.createNew(),20 input = PDFServicesSdk.FileRef.createFromLocalFile(21 'resources/splitPDFInput.pdf',22 PDFServicesSdk.SplitPDF.SupportedSourceFormat.pdf23 );24 // Set operation input from a source file.25 splitPDFOperation.setInput(input);2627 // Set the maximum number of pages each of the output files can have.28 splitPDFOperation.setPageCount(2);2930 // Execute the operation and Save the result to the specified location.31 splitPDFOperation.execute(executionContext)32 .then(result => {33 let saveFilesPromises = [];34 for(let i = 0; i < result.length; i++){35 saveFilesPromises.push(result[i].saveAsFile(`output/SplitPDFByNumberOfPagesOutput_${i}.pdf`));36 }37 return Promise.all(saveFilesPromises);38 })39 .catch(err => {40 if(err instanceof PDFServicesSdk.Error.ServiceApiError41 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {42 console.log('Exception encountered while executing operation', err);43 } else {44 console.log('Exception encountered while executing operation', err);45 }46 });47} catch (err) {48 console.log('Exception encountered while executing operation', err);49}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd SplitPDFByNumberOfPages/4// dotnet run SplitPDFByNumberOfPages.csproj56namespace SplitPDFByNumberOfPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 SplitPDFOperation splitPDFOperation = SplitPDFOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"splitPDFInput.pdf");31 splitPDFOperation.SetInput(sourceFileRef);3233 // Set the maximum number of pages each of the output files can have.34 splitPDFOperation.SetPageCount(2);3536 // Execute the operation.37 List result = splitPDFOperation.Execute(executionContext);3839 // Save the result to the specified location.40 int index = 0;41 foreach (FileRef fileRef in result)42 {43 fileRef.SaveAs(Directory.GetCurrentDirectory() + "/output/SplitPDFByNumberOfPagesOutput_" + index + ".pdf");44 index++;45 }4647 }48 catch (ServiceUsageException ex)49 {50 log.Error("Exception encountered while executing operation", ex);51 }52 // Catch more errors here . . .53 }5455 static void ConfigureLogging()56 {57 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());58 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));59 }60 }61}
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.splitpdf.SplitPDFByNumberOfPages45public class SplitPDFByNumberOfPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(SplitPDFByNumberOfPages.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 SplitPDFOperation splitPDFOperation = SplitPDFOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/splitPDFInput.pdf");24 splitPDFOperation.setInput(source);2526 // Set the maximum number of pages each of the output files can have.27 splitPDFOperation.setPageCount(2);2829 // Execute the operation.30 List result = splitPDFOperation.execute(executionContext);3132 // Save the result to the specified location.33 int index = 0;34 for (FileRef fileRef : result) {35 fileRef.saveAs("output/SplitPDFByNumberOfPagesOutput_" + index + ".pdf");36 index++;37 }3839 } catch (IOException| ServiceApiException | SdkException | ServiceUsageException e) {40 LOGGER.error("Exception encountered while executing operation", e);41 }42 }4344}
Combine multiple documents into a pdf file
Combine two or more documents into a single PDF file
See our public API Reference and quickly try our APIs using the Postman collections.
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Combine-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/combinepdf' \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 "assets": [10 {11 "assetID": "urn:aaid:AS:UE1:23c30ee0-2c4d-46d6-87f2-087832fca718"12 },13 {14 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718"15 }16 ]17}'1819// Legacy API can be found here20// https://documentcloud.adobe.com/document-services/index.html#post-combinePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/combinepdf/combine-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 combineFilesOperation = PDFServicesSdk.CombineFiles.Operation.createNew();1819 // Set operation input from a source file.20 const combineSource1 = PDFServicesSdk.FileRef.createFromLocalFile('resources/combineFilesInput1.pdf'),21 combineSource2 = PDFServicesSdk.FileRef.createFromLocalFile('resources/combineFilesInput2.pdf');22 combineFilesOperation.addInput(combineSource1);23 combineFilesOperation.addInput(combineSource2);2425 // Execute the operation and Save the result to the specified location.26 combineFilesOperation.execute(executionContext)27 .then(result => result.saveAsFile('output/combineFilesOutput.pdf'))28 .catch(err => {29 if (err instanceof PDFServicesSdk.Error.ServiceApiError30 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {31 console.log('Exception encountered while executing operation', err);32 } else {33 console.log('Exception encountered while executing operation', err);34 }35 });36} catch (err) {37 console.log('Exception encountered while executing operation', err);38}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd CombinePDF/4// dotnet run CombinePDF.csproj56namespace CombinePDF7{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 CombineFilesOperation combineFilesOperation = CombineFilesOperation.CreateNew();2627 // Add operation input from source files.28 FileRef combineSource1 = FileRef.CreateFromLocalFile(@"combineFilesInput1.pdf");29 FileRef combineSource2 = FileRef.CreateFromLocalFile(@"combineFilesInput2.pdf");30 combineFilesOperation.AddInput(combineSource1);31 combineFilesOperation.AddInput(combineSource2);3233 // Execute the operation.34 FileRef result = combineFilesOperation.Execute(executionContext);3536 // Save the result to the specified location.37 result.SaveAs(Directory.GetCurrentDirectory() + "/output/combineFilesOutput.pdf");3839 }40 catch (ServiceUsageException ex)41 {42 log.Error("Exception encountered while executing operation", ex);43 }44 // Catch more errors here. . .45 }4647 static void ConfigureLogging()48 {49 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());50 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));51 }52 }53}
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.combinepdf.CombinePDF45public class CombinePDF {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(CombinePDF.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 //Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 CombineFilesOperation combineFilesOperation = CombineFilesOperation.createNew();2122 // Add operation input from source files.23 FileRef combineSource1 = FileRef.createFromLocalFile("src/main/resources/combineFilesInput1.pdf");24 FileRef combineSource2 = FileRef.createFromLocalFile("src/main/resources/combineFilesInput2.pdf");25 combineFilesOperation.addInput(combineSource1);26 combineFilesOperation.addInput(combineSource2);2728 // Execute the operation.29 FileRef result = combineFilesOperation.execute(executionContext);3031 // Save the result to the specified location.32 result.saveAs("output/combineFilesOutput.pdf");3334 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {35 LOGGER.error("Exception encountered while executing operation", e);36 }37 }38}
Compress a pdf file
Reduce the size of PDF files by compressing to smaller sizes for lower bandwidth viewing, downloading, and sharing.
Support for multiple compression levels to retain the quality of images and graphics
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Compress-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/compresspdf' \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}'1112// Legacy API can be found here13// https://documentcloud.adobe.com/document-services/index.html#post-compressPDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/compresspdf/compress-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 compressPDF = PDFServicesSdk.CompressPDF,18 compressPDFOperation = compressPDF.Operation.createNew();1920 // Set operation input from a source file.21 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/compressPDFInput.pdf');22 compressPDFOperation.setInput(input);2324 // Execute the operation and Save the result to the specified location.25 compressPDFOperation.execute(executionContext)26 .then(result => result.saveAsFile('output/compressPDFOutput.pdf'))27 .catch(err => {28 if(err instanceof PDFServicesSdk.Error.ServiceApiError29 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {30 console.log('Exception encountered while executing operation', err);31 } else {32 console.log('Exception encountered while executing operation', err);33 }34 });35} catch (err) {36 console.log('Exception encountered while executing operation', err);37}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd CompressPDF/4// dotnet run CompressPDF.csproj56namespace CompressPDF7{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 CompressPDFOperation compressPDFOperation = CompressPDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"compressPDFInput.pdf");29 compressPDFOperation.SetInput(sourceFileRef);3031 // Execute the operation.32 FileRef result = compressPDFOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/compressPDFOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here . . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.compresspdf.CompressPDF45public class CompressPDF {6 // Initialize the logger.7 private static final Logger LOGGER = LoggerFactory.getLogger(CompressPDF.class);89 public static void main(String[] args) {1011 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 CompressPDFOperation compressPDFOperation = CompressPDFOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/compressPDFInput.pdf");24 compressPDFOperation.setInput(source);2526 // Execute the operation27 FileRef result = compressPDFOperation.execute(executionContext);2829 // Save the result at the specified location30 result.saveAs("output/compressPDFOutput.pdf");3132 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {33 LOGGER.error("Exception encountered while executing operation", ex);34 }35 }36}
Reorder pages within PDF files
Reorder the pages of a PDF file to reorganize.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Combine-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/combinepdf' \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 "assets": [10 {11 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",12 "pageRanges": [13 {14 "start": 3,15 "end": 316 },17 {18 "start": 1,19 "end": 120 },21 {22 "start": 4,23 "end": 424 }25 ]26 }27 ]28}'2930// Legacy API can be found here31// https://documentcloud.adobe.com/document-services/index.html#post-combinePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/reorderpages/reorder-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getPageRangeForReorder = () => {8 // Specify order of the pages for an output document.9 const pageRanges = new PDFServicesSdk.PageRanges();1011 // Add pages 3 to 4.12 pageRanges.addPageRange(3, 4);1314 // Add page 1.15 pageRanges.addSinglePage(1);1617 return pageRanges;18};19try {20 // Initial setup, create credentials instance.21 const credentials = PDFServicesSdk.Credentials22 .servicePrincipalCredentialsBuilder()23 .withClientId("PDF_SERVICES_CLIENT_ID")24 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")25 .build();2627 // Create an ExecutionContext using credentials and create a new operation instance.28 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),29 reorderPagesOperation = PDFServicesSdk.ReorderPages.Operation.createNew();3031 // Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.32 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/reorderPagesInput.pdf');33 const pageRanges = getPageRangeForReorder();34 reorderPagesOperation.setInput(input);35 reorderPagesOperation.setPagesOrder(pageRanges);3637 // Execute the operation and Save the result to the specified location.38 reorderPagesOperation.execute(executionContext)39 .then(result => result.saveAsFile('output/reorderPagesOutput.pdf'))40 .catch(err => {41 if(err instanceof PDFServicesSdk.Error.ServiceApiError42 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {43 console.log('Exception encountered while executing operation', err);44 } else {45 console.log('Exception encountered while executing operation', err);46 }47 });48} catch (err) {49 console.log('Exception encountered while executing operation', err);50}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ReorderPages/4// dotnet run ReorderPDFPages.csproj56namespace ReorderPDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 ReorderPagesOperation reorderPagesOperation = ReorderPagesOperation.CreateNew();2829 // Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"reorderPagesInput.pdf");31 reorderPagesOperation.SetInput(sourceFileRef);32 PageRanges pageRanges = GetPageRangeForReorder();33 reorderPagesOperation.SetPagesOrder(pageRanges);3435 // Execute the operation.36 FileRef result = reorderPagesOperation.Execute(executionContext);3738 // Save the result to the specified location.39 result.SaveAs(Directory.GetCurrentDirectory() + "/output/reorderPagesOutput.pdf");40 }41 catch (ServiceUsageException ex)42 {43 log.Error("Exception encountered while executing operation", ex);44 }45 // Catch more errors here . . .46 }4748 private static PageRanges GetPageRangeForReorder()49 {50 // Specify order of the pages for an output document.51 PageRanges pageRanges = new PageRanges();52 // Add pages 3 to 4.53 pageRanges.AddRange(3, 4);5455 // Add page 1.56 pageRanges.AddSinglePage(1);5758 return pageRanges;59 }6061 static void ConfigureLogging()62 {63 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());64 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));65 }66 }67}
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.reorderpages.ReorderPDFPages45public class ReorderPDFPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(ReorderPDFPages.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 ReorderPagesOperation reorderPagesOperation = ReorderPagesOperation.createNew();2122 // Set operation input from a source file, along with specifying the order of the pages for rearranging the pages in a PDF file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/reorderPagesInput.pdf");24 PageRanges pageRanges = getPageRangeForReorder();25 reorderPagesOperation.setInput(source);26 reorderPagesOperation.setPagesOrder(pageRanges);2728 // Execute the operation.29 FileRef result = reorderPagesOperation.execute(executionContext);3031 // Save the result to the specified location.32 result.saveAs("output/reorderPagesOutput.pdf");3334 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {35 LOGGER.error("Exception encountered while executing operation", e);36 }37 }3839 private static PageRanges getPageRangeForReorder() {40 // Specify order of the pages for an output document.41 PageRanges pageRanges = new PageRanges();42 // Add pages 3 to 4.43 pageRanges.addRange(3, 4);4445 // Add page 1.46 pageRanges.addSinglePage(1);4748 return pageRanges;49 }50}
Linearize a PDF file for fast web view
Optimize PDFs for quick viewing on the web, especially for mobile clients. Linearization allows your end users to view large PDF documents incrementally so that they can view pages much faster in lower bandwidth conditions.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Linearize-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/linearizepdf' \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}'1112// Legacy API can be found here13// https://documentcloud.adobe.com/document-services/index.html#post-linearizePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/linearizepdf/linearize-pdf.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67try {8 // Initial setup, create credentials instance.9 const credentials = PDFServicesSdk.Credentials10 .servicePrincipalCredentialsBuilder()11 .withClientId("PDF_SERVICES_CLIENT_ID")12 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")13 .build();1415 // Create an ExecutionContext using credentials and create a new operation instance.16 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),17 linearizePDF = PDFServicesSdk.LinearizePDF,18 linearizePDFOperation = linearizePDF.Operation.createNew();1920 // Set operation input from a source file.21 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/linearizePDFInput.pdf');22 linearizePDFOperation.setInput(input);2324 // Execute the operation and Save the result to the specified location.25 linearizePDFOperation.execute(executionContext)26 .then(result => result.saveAsFile('output/linearizePDFOutput.pdf'))27 .catch(err => {28 if(err instanceof PDFServicesSdk.Error.ServiceApiError29 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {30 console.log('Exception encountered while executing operation', err);31 } else {32 console.log('Exception encountered while executing operation', err);33 }34 });35} catch (err) {36 console.log('Exception encountered while executing operation', err);37}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd LinearizePDF/4// dotnet run LinearizePDF.csproj56namespace LinearizePDF7{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 LinearizePDFOperation linearizePDFOperation = LinearizePDFOperation.CreateNew();2627 // Set operation input from a source file.28 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"linearizePDFInput.pdf");29 linearizePDFOperation.SetInput(sourceFileRef);3031 // Execute the operation.32 FileRef result = linearizePDFOperation.Execute(executionContext);3334 // Save the result to the specified location.35 result.SaveAs(Directory.GetCurrentDirectory() + "/output/linearizePDFOutput.pdf");36 }37 catch (ServiceUsageException ex)38 {39 log.Error("Exception encountered while executing operation", ex);40 }41 // Catch more errors here . . .42 }4344 static void ConfigureLogging()45 {46 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());47 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));48 }49 }50}
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.linearizepdf.LinearizePDF45public class LinearizePDF {6 // Initialize the logger.7 private static final Logger LOGGER = LoggerFactory.getLogger(LinearizePDF.class);89 public static void main(String[] args) {1011 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 LinearizePDFOperation linearizePDFOperation = LinearizePDFOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/linearizePDFInput.pdf");24 linearizePDFOperation.setInput(source);2526 // Execute the operation27 FileRef result = linearizePDFOperation.execute(executionContext);2829 // Save the result at the specified location30 result.saveAs("output/linearizePDFOutput.pdf");3132 } catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {33 LOGGER.error("Exception encountered while executing operation", ex);34 }35 }36}
Insert a page into a PDF document
Insert one or more pages into an existing document
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Combine-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/combinepdf' \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 "assets": [10 {11 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",12 "pageRanges": [13 {14 "start": 1,15 "end": 116 }17 ]18 },19 {20 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",21 "pageRanges": [22 {23 "start": 424 }25 ]26 },27 {28 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",29 "pageRanges": [30 {31 "start": 132 }33 ]34 },35 {36 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",37 "pageRanges": [38 {39 "start": 240 }41 ]42 }43 ]44}'4546// Legacy API can be found here47// https://documentcloud.adobe.com/document-services/index.html#post-combinePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/insertpages/insert-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getPageRangesForFirstFile = () => {8 // Specify which pages of the first file are to be inserted in the base file.9 const pageRangesForFirstFile = new PDFServicesSdk.PageRanges();10 // Add pages 1 to 3.11 pageRangesForFirstFile.addPageRange(1, 3);1213 // Add page 4.14 pageRangesForFirstFile.addSinglePage(4);1516 return pageRangesForFirstFile;17};1819try {20 // Initial setup, create credentials instance.21 const credentials = PDFServicesSdk.Credentials22 .servicePrincipalCredentialsBuilder()23 .withClientId("PDF_SERVICES_CLIENT_ID")24 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")25 .build();2627 // Create an ExecutionContext using credentials and create a new operation instance.28 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),29 insertPagesOperation = PDFServicesSdk.InsertPages.Operation.createNew();3031 // Set operation base input from a source file.32 const baseInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/baseInput.pdf');33 insertPagesOperation.setBaseInput(baseInputFile);3435 // Create a FileRef instance using a local file.36 const firstFileToInsert = PDFServicesSdk.FileRef.createFromLocalFile('resources/firstFileToInsertInput.pdf'),37 pageRanges = getPageRangesForFirstFile();3839 // Adds the pages (specified by the page ranges) of the input PDF file to be inserted at the specified page of the base PDF file.40 insertPagesOperation.addPagesToInsertAt(2, firstFileToInsert, pageRanges);4142 // Create a FileRef instance using a local file.43 const secondFileToInsert = PDFServicesSdk.FileRef.createFromLocalFile('resources/secondFileToInsertInput.pdf');4445 // Adds all the pages of the input PDF file to be inserted at the specified page of the base PDF file.46 insertPagesOperation.addPagesToInsertAt(3, secondFileToInsert);4748 // Execute the operation and Save the result to the specified location.49 insertPagesOperation.execute(executionContext)50 .then(result => result.saveAsFile('output/insertPagesOutput.pdf'))51 .catch(err => {52 if (err instanceof PDFServicesSdk.Error.ServiceApiError53 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {54 console.log('Exception encountered while executing operation', err);55 } else {56 console.log('Exception encountered while executing operation', err);57 }58 });59} catch (err) {60 console.log('Exception encountered while executing operation', err);61}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd InsertPDFPages/4// dotnet run InsertPDFPages.csproj56namespace InsertPDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 InsertPagesOperation insertPagesOperation = InsertPagesOperation.CreateNew();2829 // Set operation base input from a source file.30 FileRef baseSourceFile = FileRef.CreateFromLocalFile(@"baseInput.pdf");31 insertPagesOperation.SetBaseInput(baseSourceFile);3233 // Create a FileRef instance using a local file.34 FileRef firstFileToInsert = FileRef.CreateFromLocalFile(@"firstFileToInsertInput.pdf");35 PageRanges pageRanges = GetPageRangeForFirstFile();3637 // Adds the pages (specified by the page ranges) of the input PDF file to be inserted at the specified page of the base PDF file.38 insertPagesOperation.AddPagesToInsertAt(firstFileToInsert, pageRanges, 2);3940 // Create a FileRef instance using a local file.41 FileRef secondFileToInsert = FileRef.CreateFromLocalFile(@"secondFileToInsertInput.pdf");4243 // Adds all the pages of the input PDF file to be inserted at the specified page of the base PDF file.44 insertPagesOperation.AddPagesToInsertAt(secondFileToInsert, 3);4546 // Execute the operation.47 FileRef result = insertPagesOperation.Execute(executionContext);4849 // Save the result to the specified location.50 result.SaveAs(Directory.GetCurrentDirectory() + "/output/insertPagesOutput.pdf");51 }52 catch (ServiceUsageException ex)53 {54 log.Error("Exception encountered while executing operation", ex);55 // Catch more errors here . . .56 }5758 private static PageRanges GetPageRangeForFirstFile()59 {60 // Specify which pages of the first file are to be inserted in the base file.61 PageRanges pageRanges = new PageRanges();62 // Add pages 1 to 3.63 pageRanges.AddRange(1, 3);6465 // Add page 4.66 pageRanges.AddSinglePage(4);6768 return pageRanges;69 }7071 static void ConfigureLogging()72 {73 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());74 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));75 }76 }77}
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.insertpages.InsertPDFPages45public class InsertPDFPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(InsertPDFPages.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 InsertPagesOperation insertPagesOperation = InsertPagesOperation.createNew();2122 // Set operation base input from a source file.23 FileRef baseSourceFile = FileRef.createFromLocalFile("src/main/resources/baseInput.pdf");24 insertPagesOperation.setBaseInput(baseSourceFile);2526 // Create a FileRef instance using a local file.27 FileRef firstFileToInsert = FileRef.createFromLocalFile("src/main/resources/firstFileToInsertInput.pdf");28 PageRanges pageRanges = getPageRangeForFirstFile();2930 // Adds the pages (specified by the page ranges) of the input PDF file to be inserted at the specified page of the base PDF file.31 insertPagesOperation.addPagesToInsertAt(firstFileToInsert, pageRanges, 2);3233 // Create a FileRef instance using a local file.34 FileRef secondFileToInsert = FileRef.createFromLocalFile("src/main/resources/secondFileToInsertInput.pdf");3536 // Adds all the pages of the input PDF file to be inserted at the specified page of the base PDF file.37 insertPagesOperation.addPagesToInsertAt(secondFileToInsert, 3);3839 // Execute the operation.40 FileRef result = insertPagesOperation.execute(executionContext);4142 // Save the result to the specified location.43 result.saveAs("output/insertPagesOutput.pdf");4445 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {46 LOGGER.error("Exception encountered while executing operation", e);47 }48 }4950 private static PageRanges getPageRangeForFirstFile() {51 // Specify which pages of the first file are to be inserted in the base file.52 PageRanges pageRanges = new PageRanges();53 // Add pages 1 to 3.54 pageRanges.addRange(1, 3);5556 // Add page 4.57 pageRanges.addSinglePage(4);5859 return pageRanges;60 }61}
Replace a page within a PDF file
Replace one or more pages with another page in an existing document
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Combine-PDF34curl --location --request POST 'https://pdf-services.adobe.io/operation/combinepdf' \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 "assets": [10 {11 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",12 "pageRanges": [13 {14 "start": 1,15 "end": 116 }17 ]18 },19 {20 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",21 "pageRanges": [22 {23 "start": 224 }25 ]26 },27 {28 "assetID": "urn:aaid:AS:UE1:23c30ee0-2e4d-46d6-87f2-087832fca718",29 "pageRanges": [30 {31 "start": 332 }33 ]34 }35 ]36}'37// Legacy API can be found here38// https://documentcloud.adobe.com/document-services/index.html#post-combinePDF
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/replacepages/replace-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getPageRangesForFirstFile = () => {8 // Specify pages of the first file for replacing the page of base PDF file.9 const pageRangesForFirstFile = new PDFServicesSdk.PageRanges();10 // Add pages 1 to 3.11 pageRangesForFirstFile.addPageRange(1, 3);1213 // Add page 4.14 pageRangesForFirstFile.addSinglePage(4);1516 return pageRangesForFirstFile;17};1819try {20 // Initial setup, create credentials instance.21 const credentials = PDFServicesSdk.Credentials22 .servicePrincipalCredentialsBuilder()23 .withClientId("PDF_SERVICES_CLIENT_ID")24 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")25 .build();2627 // Create an ExecutionContext using credentials and create a new operation instance.28 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),29 replacePagesOperation = PDFServicesSdk.ReplacePages.Operation.createNew();3031 // Set operation base input from a source file.32 const baseInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/baseInput.pdf');33 replacePagesOperation.setBaseInput(baseInputFile);3435 // Create a FileRef instance using a local file.36 const firstInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/replacePagesInput1.pdf'),37 pageRanges = getPageRangesForFirstFile();3839 // Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.40 replacePagesOperation.addPagesForReplace(1, firstInputFile, pageRanges);4142 // Create a FileRef instance using a local file.43 const secondInputFile = PDFServicesSdk.FileRef.createFromLocalFile('resources/replacePagesInput2.pdf');4445 // Adds all the pages of the input PDF file for replacing the page of the base PDF file.46 replacePagesOperation.addPagesForReplace(3, secondInputFile);4748 // Execute the operation and Save the result to the specified location.49 replacePagesOperation.execute(executionContext)50 .then(result => result.saveAsFile('output/replacePagesOutput.pdf'))51 .catch(err => {52 if (err instanceof PDFServicesSdk.Error.ServiceApiError53 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {54 console.log('Exception encountered while executing operation', err);55 } else {56 console.log('Exception encountered while executing operation', err);57 }58 });59} catch (err) {60 console.log('Exception encountered while executing operation', err);61}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd ReplacePDFPages/4// dotnet run ReplacePDFPages.csproj56namespace ReplacePDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 ReplacePagesOperation replacePagesOperation = ReplacePagesOperation.CreateNew();2829 // Set operation base input from a source file.30 FileRef baseSourceFile = FileRef.CreateFromLocalFile(@"baseInput.pdf");31 replacePagesOperation.SetBaseInput(baseSourceFile);3233 // Create a FileRef instance using a local file.34 FileRef firstInputFile = FileRef.CreateFromLocalFile(@"replacePagesInput1.pdf");35 PageRanges pageRanges = GetPageRangeForFirstFile();3637 // Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.38 replacePagesOperation.AddPagesForReplace(firstInputFile, pageRanges, 1);3940 // Create a FileRef instance using a local file.41 FileRef secondInputFile = FileRef.CreateFromLocalFile(@"replacePagesInput2.pdf");4243 // Adds all the pages of the input PDF file for replacing the page of the base PDF file.44 replacePagesOperation.AddPagesForReplace(secondInputFile, 3);4546 // Execute the operation.47 FileRef result = replacePagesOperation.Execute(executionContext);4849 // Save the result to the specified location.50 result.SaveAs(Directory.GetCurrentDirectory() + "/output/replacePagesOutput.pdf");51 }52 catch (ServiceUsageException ex)53 {54 log.Error("Exception encountered while executing operation", ex);55 // Catch more errors here . . .56 }5758 private static PageRanges GetPageRangeForFirstFile()59 {60 // Specify pages of the first file for replacing the page of base PDF file.61 PageRanges pageRanges = new PageRanges();62 // Add pages 1 to 3.63 pageRanges.AddRange(1, 3);6465 // Add page 4.66 pageRanges.AddSinglePage(4);6768 return pageRanges;69 }7071 static void ConfigureLogging()72 {73 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());74 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));75 }76 }77}
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.replacepages.ReplacePDFPages45public class ReplacePDFPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(ReplacePDFPages.class);910 public static void main(String[] args) {1112 try {13 // Initial setup, create credentials instance.14 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()15 .withClientId("PDF_SERVICES_CLIENT_ID")16 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")17 .build();1819 // Create an ExecutionContext using credentials and create a new operation instance.20 ExecutionContext executionContext = ExecutionContext.create(credentials);21 ReplacePagesOperation replacePagesOperation = ReplacePagesOperation.createNew();2223 // Set operation base input from a source file.24 FileRef baseSourceFile = FileRef.createFromLocalFile("src/main/resources/baseInput.pdf");25 replacePagesOperation.setBaseInput(baseSourceFile);2627 // Create a FileRef instance using a local file.28 FileRef firstInputFile = FileRef.createFromLocalFile("src/main/resources/replacePagesInput1.pdf");29 PageRanges pageRanges = getPageRangeForFirstFile();3031 // Adds the pages (specified by the page ranges) of the input PDF file for replacing the page of the base PDF file.32 replacePagesOperation.addPagesForReplace(firstInputFile, pageRanges, 1);333435 // Create a FileRef instance using a local file.36 FileRef secondInputFile = FileRef.createFromLocalFile("src/main/resources/replacePagesInput2.pdf");3738 // Adds all the pages of the input PDF file for replacing the page of the base PDF file.39 replacePagesOperation.addPagesForReplace(secondInputFile, 3);4041 // Execute the operation42 FileRef result = replacePagesOperation.execute(executionContext);4344 // Save the result at the specified location45 result.saveAs("output/replacePagesOutput.pdf");46 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {47 LOGGER.error("Exception encountered while executing operation", e);48 }49 }5051 private static PageRanges getPageRangeForFirstFile() {52 // Specify pages of the first file for replacing the page of base PDF file.53 PageRanges pageRanges = new PageRanges();54 // Add pages 1 to 3.55 pageRanges.addRange(1, 3);5657 // Add page 4.58 pageRanges.addSinglePage(4);5960 return pageRanges;61 }62}
Delete a page from a PDF file
Delete one or more pages from a document
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Page-Manipulation34curl --location --request POST 'https://pdf-services.adobe.io/operation/pagemanipulation' \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 "pageActions": [11 {12 "delete": {13 "pageRanges": [14 {15 "start": 1,16 "end": 217 }18 ]19 }20 }21 ]22}'2324// Legacy API can be found here25// https://documentcloud.adobe.com/document-services/index.html#post-pageManipulation
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/replacepages/replace-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getPageRangesForDeletion = () => {8 // Specify pages for deletion.9 const pageRangesForDeletion = new PDFServicesSdk.PageRanges();10 // Add page 1.11 pageRangesForDeletion.addSinglePage(1);1213 // Add pages 3 to 4.14 pageRangesForDeletion.addPageRange(3, 4);15 return pageRangesForDeletion;16};1718try {19 // Initial setup, create credentials instance.20 const credentials = PDFServicesSdk.Credentials21 .servicePrincipalCredentialsBuilder()22 .withClientId("PDF_SERVICES_CLIENT_ID")23 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")24 .build();2526 // Create an ExecutionContext using credentials and create a new operation instance.27 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),28 deletePagesOperation = PDFServicesSdk.DeletePages.Operation.createNew();2930 // Set operation input from a source file.31 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/deletePagesInput.pdf');32 deletePagesOperation.setInput(input);3334 // Delete pages of the document (as specified by PageRanges).35 const pageRangesForDeletion = getPageRangesForDeletion();36 deletePagesOperation.setPageRanges(pageRangesForDeletion);3738 // Execute the operation and Save the result to the specified location.39 deletePagesOperation.execute(executionContext)40 .then(result => result.saveAsFile('output/deletePagesOutput.pdf'))41 .catch(err => {42 if (err instanceof PDFServicesSdk.Error.ServiceApiError43 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {44 console.log('Exception encountered while executing operation', err);45 } else {46 console.log('Exception encountered while executing operation', err);47 }48 });49} catch (err) {50 console.log('Exception encountered while executing operation', err);51}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd DeletePDFPages/4// dotnet run DeletePDFPages.csproj56namespace DeletePDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 DeletePagesOperation deletePagesOperation = DeletePagesOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"deletePagesInput.pdf");31 deletePagesOperation.SetInput(sourceFileRef);3233 // Delete pages of the document (as specified by PageRanges).34 PageRanges pageRangeForDeletion = GetPageRangeForDeletion();35 deletePagesOperation.SetPageRanges(pageRangeForDeletion);3637 // Execute the operation.38 FileRef result = deletePagesOperation.Execute(executionContext);3940 // Save the result to the specified location.41 result.SaveAs(Directory.GetCurrentDirectory() + "/output/deletePagesOutput.pdf");42 }43 catch (ServiceUsageException ex)44 {45 log.Error("Exception encountered while executing operation", ex);46 }47 // Catch more errors here . . .48 }4950 private static PageRanges GetPageRangeForDeletion()51 {52 // Specify pages for deletion.53 PageRanges pageRangeForDeletion = new PageRanges();54 // Add page 1.55 pageRangeForDeletion.AddSinglePage(1);5657 // Add pages 3 to 4.58 pageRangeForDeletion.AddRange(3, 4);59 return pageRangeForDeletion;60 }6162 static void ConfigureLogging()63 {64 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());65 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));66 }67 }68}
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.deletepages.DeletePDFPages456public class DeletePDFPages {78// Initialize the logger.9private static final Logger LOGGER = LoggerFactory.getLogger(DeletePDFPages.class);1011public static void main(String[] args) {12 try {13 // Initial setup, create credentials instance.14 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()15 .withClientId("PDF_SERVICES_CLIENT_ID")16 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")17 .build();1819 // Create an ExecutionContext using credentials and create a new operation instance.20 ExecutionContext executionContext = ExecutionContext.create(credentials);21 DeletePagesOperation deletePagesOperation = DeletePagesOperation.createNew();2223 // Set operation input from a source file.24 FileRef source = FileRef.createFromLocalFile("src/main/resources/deletePagesInput.pdf");25 deletePagesOperation.setInput(source);2627 // Delete pages of the document (as specified by PageRanges).28 PageRanges pageRangeForDeletion = getPageRangeForDeletion();29 deletePagesOperation.setPageRanges(pageRangeForDeletion);3031 // Execute the operation.32 FileRef result = deletePagesOperation.execute(executionContext);3334 // Save the result to the specified location.35 result.saveAs("output/deletePagesOutput.pdf");3637 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {38 LOGGER.error("Exception encountered while executing operation", e);39 }40 }4142 private static PageRanges getPageRangeForDeletion() {43 // Specify pages for deletion.44 PageRanges pageRangeForDeletion = new PageRanges();45 // Add page 1.46 pageRangeForDeletion.addSinglePage(1);4748 // Add pages 3 to 4.49 pageRangeForDeletion.addRange(3, 4);50 return pageRangeForDeletion;51 }52}
Rotate a page in a PDF file
Rotate a page in an existing document.
See our public API Reference and quickly try our APIs using the Postman collections
Copied to your clipboard1// Please refer our Rest API docs for more information2// https://developer.adobe.com/document-services/docs/apis/#tag/Page-Manipulation34curl --location --request POST 'https://pdf-services.adobe.io/operation/pagemanipulation' \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-087832fca718f",10 "pageActions": [11 {12 "rotate": {13 "angle": 90,14 "pageRanges": [15 {16 "start": 117 }18 ]19 }20 },21 {22 "rotate": {23 "angle": 180,24 "pageRanges": [25 {26 "start": 2,27 "end": 228 }29 ]30 }31 }32 ]33}'3435// Legacy API can be found here36// https://documentcloud.adobe.com/document-services/index.html#post-pageManipulation
Copied to your clipboard1// Get the samples from http://www.adobe.com/go/pdftoolsapi_node_sample2// Run the sample:3// node src/rotatepages/rotate-pdf-pages.js45const PDFServicesSdk = require('@adobe/pdfservices-node-sdk');67const getFirstPageRangeForRotation = () => {8 // Specify pages for rotation.9 const firstPageRange = new PDFServicesSdk.PageRanges();10 // Add page 1.11 firstPageRange.addSinglePage(1);1213 // Add pages 3 to 4.14 firstPageRange.addPageRange(3, 4);1516 return firstPageRange;17};1819const getSecondPageRangeForRotation = () => {20 // Specify pages for rotation.21 const secondPageRange = new PDFServicesSdk.PageRanges();22 // Add page 2.23 secondPageRange.addSinglePage(2);2425 return secondPageRange;26};2728try {29 // Initial setup, create credentials instance.30 const credentials = PDFServicesSdk.Credentials31 .servicePrincipalCredentialsBuilder()32 .withClientId("PDF_SERVICES_CLIENT_ID")33 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")34 .build();3536 // Create an ExecutionContext using credentials and create a new operation instance.37 const executionContext = PDFServicesSdk.ExecutionContext.create(credentials),38 rotatePagesOperation = PDFServicesSdk.RotatePages.Operation.createNew();3940 // Set operation input from a source file.41 const input = PDFServicesSdk.FileRef.createFromLocalFile('resources/rotatePagesInput.pdf');42 rotatePagesOperation.setInput(input);4344 // Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.45 const firstPageRange = getFirstPageRangeForRotation();46 rotatePagesOperation.setAngleToRotatePagesBy(PDFServicesSdk.RotatePages.Angle._90, firstPageRange);4748 // Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.49 const secondPageRange = getSecondPageRangeForRotation();50 rotatePagesOperation.setAngleToRotatePagesBy(PDFServicesSdk.RotatePages.Angle._180,secondPageRange);5152 // Execute the operation and Save the result to the specified location.53 rotatePagesOperation.execute(executionContext)54 .then(result => result.saveAsFile('output/rotatePagesOutput.pdf'))55 .catch(err => {56 if (err instanceof PDFServicesSdk.Error.ServiceApiError57 || err instanceof PDFServicesSdk.Error.ServiceUsageError) {58 console.log('Exception encountered while executing operation', err);59 } else {60 console.log('Exception encountered while executing operation', err);61 }62 });63} catch (err) {64 console.log('Exception encountered while executing operation', err);65}
Copied to your clipboard1// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples2// Run the sample:3// cd RotatePDFPages/4// dotnet run RotatePDFPages.csproj56namespace RotatePDFPages7{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.24 ExecutionContext executionContext = ExecutionContext.Create(credentials);2526 // Create a new operation instance27 RotatePagesOperation rotatePagesOperation = RotatePagesOperation.CreateNew();2829 // Set operation input from a source file.30 FileRef sourceFileRef = FileRef.CreateFromLocalFile(@"rotatePagesInput.pdf");31 rotatePagesOperation.SetInput(sourceFileRef);3233 // Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.34 PageRanges firstPageRange = GetFirstPageRangeForRotation();35 rotatePagesOperation.SetAngleToRotatePagesBy(Angle._90, firstPageRange);3637 // Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.38 PageRanges secondPageRange = GetSecondPageRangeForRotation();39 rotatePagesOperation.SetAngleToRotatePagesBy(Angle._180, secondPageRange);4041 // Execute the operation.42 FileRef result = rotatePagesOperation.Execute(executionContext);4344 // Save the result to the specified location.45 result.SaveAs(Directory.GetCurrentDirectory() + "/output/rotatePagesOutput.pdf");46 }47 catch (ServiceUsageException ex)48 {49 log.Error("Exception encountered while executing operation", ex);50 }51 // Catch more errors here . . .52 }5354 static void ConfigureLogging()55 {56 ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());57 XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));58 }5960 private static PageRanges GetFirstPageRangeForRotation()61 {62 // Specify pages for rotation.63 PageRanges firstPageRange = new PageRanges();64 // Add page 1.65 firstPageRange.AddSinglePage(1);6667 // Add pages 3 to 4.68 firstPageRange.AddRange(3, 4);69 return firstPageRange;70 }7172 private static PageRanges GetSecondPageRangeForRotation()73 {74 // Specify pages for rotation.75 PageRanges secondPageRange = new PageRanges();76 // Add page 2.77 secondPageRange.AddSinglePage(2);7879 return secondPageRange;80 }81 }82}
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.rotatepages.RotatePDFPages45public class RotatePDFPages {67 // Initialize the logger.8 private static final Logger LOGGER = LoggerFactory.getLogger(RotatePDFPages.class);910 public static void main(String[] args) {11 try {12 // Initial setup, create credentials instance.13 Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()14 .withClientId("PDF_SERVICES_CLIENT_ID")15 .withClientSecret("PDF_SERVICES_CLIENT_SECRET")16 .build();1718 // Create an ExecutionContext using credentials and create a new operation instance.19 ExecutionContext executionContext = ExecutionContext.create(credentials);20 RotatePagesOperation rotatePagesOperation = RotatePagesOperation.createNew();2122 // Set operation input from a source file.23 FileRef source = FileRef.createFromLocalFile("src/main/resources/rotatePagesInput.pdf");24 rotatePagesOperation.setInput(source);2526 // Sets angle by 90 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.27 PageRanges firstPageRange = getFirstPageRangeForRotation();28 rotatePagesOperation.setAngleToRotatePagesBy(Angle._90, firstPageRange);2930 // Sets angle by 180 degrees (in clockwise direction) for rotating the specified pages of the input PDF file.31 PageRanges secondPageRange = getSecondPageRangeForRotation();32 rotatePagesOperation.setAngleToRotatePagesBy(Angle._180, secondPageRange);3334 // Execute the operation.35 FileRef result = rotatePagesOperation.execute(executionContext);3637 // Save the result to the specified location.38 result.saveAs("output/rotatePagesOutput.pdf");3940 } catch (IOException | ServiceApiException | SdkException | ServiceUsageException e) {41 LOGGER.error("Exception encountered while executing operation", e);42 }43 }4445 private static PageRanges getFirstPageRangeForRotation() {46 // Specify pages for rotation.47 PageRanges firstPageRange = new PageRanges();48 // Add page 1.49 firstPageRange.addSinglePage(1);5051 // Add pages 3 to 4.52 firstPageRange.addRange(3, 4);53 return firstPageRange;54 }5556 private static PageRanges getSecondPageRangeForRotation() {57 // Specify pages for rotation.58 PageRanges secondPageRange = new PageRanges();59 // Add page 2.60 secondPageRange.addSinglePage(2);6162 return secondPageRange;63 }64}
Adobe PDF Extract API
A new web service that allows you to unlock content structure and table data from any PDF document with machine learning.
Leverage Adobe Sensei for a rich understanding of content structure with higher quality input to other systems.
Easily Extract content to JSON format for further processing into other applications or databases.
Identify more document elements than OCR with extraction of headings, paragraphs, lists, and more.
Use cases for PDF Services API
Report creation and editing
Create and embed reports for internal or external consumption, sharing, and review.
Search and Indexing
Create searchable indexes from digital documents to quickly locate critical content for compliance and other downstream processing.
Digital content publishing
Publish whitepapers and marketing content with end-user interactivity, security controls, and analytics.
Job posting
Automate job posting with supporting documents such as PDF brochures, relevant job supplements, and company details.