public class ExportPDFOperation extends Object implements Operation
ExportPDFTargetFormat
.
For the image target formats (JPEG and PNG), the resulting file is a ZIP archive containing one image per page of the source PDF file. Each image file name ends with "_<unpadded_page_index>". 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".
Sample Usage:
ExportPDFOperation exportPdfOperation = ExportPDFOperation.createNew(ExportPDFTargetFormat.DOCX);
exportPdfOperation.setInput(FileRef.createFromLocalFile("~/Documents/exportPdfInput.pdf",
ExportPDFOperation.SupportedSourceFormat.PDF.getMediaType()));
Credentials credentials = Credentials.serviceAccountCredentialsBuilder().fromFile("pdftools-api-credentials.json").build();
FileRef result = exportPdfOperation.execute(ExecutionContext.create(credentials));
result.saveAs("output/ExportPDFOutput.docx");
Modifier and Type | Class and Description |
---|---|
static class |
ExportPDFOperation.SupportedSourceFormat
Supported source file formats for
ExportPDFOperation . |
Modifier and Type | Method and Description |
---|---|
static ExportPDFOperation |
createNew(ExportPDFTargetFormat exportPDFTargetFormat)
Constructs a
ExportPDFOperation instance. |
FileRef |
execute(ExecutionContext context)
Executes this operation synchronously using the supplied context and returns a new FileRef instance for the resulting file.
|
void |
setInput(FileRef sourceFileRef)
Sets an input PDF file (media type "application/pdf").
|
public static ExportPDFOperation createNew(ExportPDFTargetFormat exportPDFTargetFormat)
ExportPDFOperation
instance.exportPDFTargetFormat
- target formatExportPDFOperation
instancepublic void setInput(FileRef sourceFileRef)
sourceFileRef
- an input PDF filepublic FileRef execute(ExecutionContext context) throws ServiceApiException, IOException, ServiceUsageException
The resulting file may be stored in the system temporary directory (per java.io.tmpdir System property).
See FileRef
for how temporary resources are cleaned up.
execute
in interface Operation
context
- the context in which to execute the operationServiceApiException
- if an API call results in an error responseIOException
- if there is an error in reading either the input source or the resulting fileServiceUsageException
- if service usage limits have been reached or credentials quota has been exhausted.Copyright © 2020 Adobe. All rights reserved.