public class ExportPDFToImagesOperation extends Object implements Operation
ExportPDFToImagesTargetFormat
.
The result is a list of images. For example, a PDF file with 15 pages will generate 15 image files. The first file's name ends with "_0" and the last file's name ends with "_14".
Sample Usage: ExportPDFToImagesOperation exportPDFToImagesOperation = ExportPDFToImagesOperation.createNew(ExportPDFToImagesTargetFormat.PNG);
ExportPDFToImagesOperation.setInput(FileRef.createFromLocalFile("~/Documents/exportPDFToImagesOperationInput.pdf",
ExportPDFToImagesOperation.SupportedSourceFormat.PDF.getMediaType()));
Credentials credentials = Credentials.serviceAccountCredentialsBuilder().fromFile("pdfservices-api-credentials.json").build();
List<FileRef> result = ExportPDFToImagesOperation.execute(ExecutionContext.create(credentials));
int index = 0;
for (FileRef fileRef : result) {
fileRef.saveAs("output/exportPDFToImagesOperationOutput_" + index + ExportPDFToImagesTargetFormat.PNG);
index++;
}
Modifier and Type | Class and Description |
---|---|
static class |
ExportPDFToImagesOperation.SupportedSourceFormat
Supported source file formats for
ExportPDFToImagesOperation . |
Modifier and Type | Method and Description |
---|---|
static ExportPDFToImagesOperation |
createNew(ExportPDFToImagesTargetFormat exportPDFToImagesTargetFormat)
Constructs a
ExportPDFToImagesOperation instance. |
List<FileRef> |
execute(ExecutionContext context)
Executes this operation synchronously using the supplied context and returns a new list of FileRef instances for the resultant image files.
|
void |
setInput(FileRef sourceFileRef)
Sets an input PDF file (media type "application/pdf").
|
void |
setOutputType(OutputType outputType)
Sets the outputType for this operation.
|
public static ExportPDFToImagesOperation createNew(ExportPDFToImagesTargetFormat exportPDFToImagesTargetFormat)
ExportPDFToImagesOperation
instance.exportPDFToImagesTargetFormat
- target formatExportPDFToImagesOperation
instancepublic void setInput(FileRef sourceFileRef)
sourceFileRef
- an input PDF filepublic void setOutputType(OutputType outputType)
OutputType
for how to specify the outputType for getting either a list of page images or zip of page images.outputType
- - optional parameters; OutputType.LIST_OF_PAGE_IMAGES
is used as default value.public List<FileRef> execute(ExecutionContext context) throws ServiceApiException, IOException, ServiceUsageException
The resultant files 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 image fileServiceUsageException
- if service usage limits have been reached or credentials quota has been exhaustedCopyright © 2022 Adobe. All rights reserved.