Edit in GitHubLog an issue

Export PDF

Export a source PDF file into doc, docx, jpeg, png, pptx, rtf, xlsx.

Rest API

See our public API Reference for :

Export a PDF

The sample below converts a PDF file into a number of supported formats such as:

  • Microsoft Office file formats
  • Text files

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

Copied to your clipboard
// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
// Run the sample:
// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.exportpdf.ExportPDFToDOCX
public class ExportPDFToDOCX {
// Initialize the logger.
private static final Logger LOGGER = LoggerFactory.getLogger(ExportPDFToDOCX.class);
public static void main(String[] args) {
try {
// Initial setup, create credentials instance.
Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()
.withClientId("PDF_SERVICES_CLIENT_ID")
.withClientSecret("PDF_SERVICES_CLIENT_SECRET")
.build();
//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
ExportPDFOperation exportPdfOperation = ExportPDFOperation.createNew(ExportPDFTargetFormat.DOCX);
// Set operation input from a local PDF file
FileRef sourceFileRef = FileRef.createFromLocalFile("src/main/resources/exportPDFInput.pdf");
exportPdfOperation.setInput(sourceFileRef);
// Execute the operation.
FileRef result = exportPdfOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/exportPdfOutput.docx");
} catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {
LOGGER.error("Exception encountered while executing operation", ex);
}
}
}

Export a PDF file to a DOCX file (apply OCR on the PDF file)

The sample below converts a PDF file into a number of supported formats such as:

  • Microsoft Office file formats
  • Text files

OCR processing is also performed on the input PDF file to extract text from images in the document.

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

Copied to your clipboard
// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
// Run the sample:
// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.exportpdf.ExportPDFToDOCXWithOCROption
public class ExportPDFToDOCXWithOCROption {
// Initialize the logger.
private static final Logger LOGGER = LoggerFactory.getLogger(ExportPDFToDOCXWithOCROption.class);
public static void main(String[] args) {
try {
// Initial setup, create credentials instance.
Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()
.withClientId("PDF_SERVICES_CLIENT_ID")
.withClientSecret("PDF_SERVICES_CLIENT_SECRET")
.build();
//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
ExportPDFOperation exportPDFOperation = ExportPDFOperation.createNew(ExportPDFTargetFormat.DOCX);
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.createFromLocalFile("src/main/resources/exportPDFInput.pdf");
exportPDFOperation.setInput(sourceFileRef);
// Create a new ExportPDFOptions instance from the specified OCR locale and set it into the operation.
ExportPDFOptions exportPDFOptions = new ExportPDFOptions(ExportOCRLocale.EN_US);
exportPDFOperation.setOptions(exportPDFOptions);
// Create a new ExportPDFOptions instance from the specified OCR locale and set it into the operation.
ExportPDFOptions exportPDFOptions = new ExportPDFOptions(ExportOCRLocale.EN_US);
exportPDFOperation.setOptions(exportPDFOptions);
// Execute the operation.
FileRef result = exportPDFOperation.execute(executionContext);
// Save the result to the specified location.
result.saveAs("output/exportPDFWithOCROptionsOutput.docx");
} catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {
LOGGER.error("Exception encountered while executing operation", ex);
}
}
}

Export a PDF to images

The sample below converts a PDF file's pages to a list of JPEG images. Each image file name ends with "_\<unpadded_page_index_number>". For example, a PDF file with 15 pages will generate 15 image files. The first file's name ends with "_1" and the last file's name ends with "_15".

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

Copied to your clipboard
// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
// Run the sample:
// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.exportpdftoimages.ExportPDFToJPEG
public class ExportPDFToJPEG {
// Initialize the logger.
private static final Logger LOGGER = LoggerFactory.getLogger(ExportPDFToJPEG.class);
public static void main(String[] args) {
try {
// Initial setup, create credentials instance.
Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()
.withClientId("PDF_SERVICES_CLIENT_ID")
.withClientSecret("PDF_SERVICES_CLIENT_SECRET")
.build();
// Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
ExportPDFOperation exportPdfOperation = ExportPDFOperation.createNew(ExportPDFTargetFormat.JPEG);
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.createFromLocalFile("src/main/resources/exportPDFToImageInput.pdf");
exportPdfOperation.setInput(sourceFileRef);
// Execute the operation.
List<FileRef> results = exportPDFToImagesOperation.execute(executionContext);
// Save the result to the specified location.
int index = 0;
for(FileRef result : results) {
result.saveAs("output/exportPDFToImagesOutput_" + index + ".jpeg");
index++;
}
} catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {
LOGGER.error("Exception encountered while executing operation", ex);
}
}
}

Export a PDF to zip of page images

The sample below converts a PDF file to one or more jpeg or png images. The resulting file is a ZIP archive containing one image per page of the source PDF file.

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

Copied to your clipboard
// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
// Run the sample:
// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.exportpdftoimages.ExportPDFToJPEGZip
public class ExportPDFToJPEGZip {
// Initialize the logger.
private static final Logger LOGGER = LoggerFactory.getLogger(ExportPDFToJPEGZip.class);
public static void main(String[] args) {
try {
// Initial setup, create credentials instance.
Credentials credentials = Credentials.servicePrincipalCredentialsBuilder()
.withClientId("PDF_SERVICES_CLIENT_ID")
.withClientSecret("PDF_SERVICES_CLIENT_SECRET")
.build();
//Create an ExecutionContext using credentials and create a new operation instance.
ExecutionContext executionContext = ExecutionContext.create(credentials);
ExportPDFToImagesOperation exportPDFToImagesOperation = ExportPDFToImagesOperation.createNew(ExportPDFToImagesTargetFormat.JPEG);
// Set operation input from a source file.
FileRef sourceFileRef = FileRef.createFromLocalFile("src/main/resources/exportPDFToImageInput.pdf");
exportPDFToImagesOperation.setInput(sourceFileRef);
// Set the output type to create zip of images.
exportPDFToImagesOperation.setOutputType(OutputType.ZIP_OF_PAGE_IMAGES);
// Execute the operation.
List<FileRef> results = exportPDFToImagesOperation.execute(executionContext);
// Save the result to the specified location.
results.get(0).saveAs("output/exportPDFToJPEGOutput.zip");
} catch (ServiceApiException | IOException | SdkException | ServiceUsageException ex) {
LOGGER.error("Exception encountered while executing operation", ex);
}
}
}
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.