public class ExtractPDFOperation extends Object implements Operation
ExtractPDFOperation extractPDFOperation = ExtractPDFOperation.createNew();
extractPDFOperation.setInputFile(FileRef.createFromLocalFile("src/test/resources/extractPdfInput.pdf"));
ExtractPDFOptions extractPDFOptions = ExtractPDFOptions.extractPdfOptionsBuilder().addElementsToExtract(Arrays.asList(ExtractElementType.TEXT)).build();
extractPDFOperation.setOptions(extractPDFOptions);
Credentials credentials = Credentials.serviceAccountCredentialsBuilder().fromFile("pdfservices-api-credentials.json").build();
FileRef result = extractPDFOperation.execute(ExecutionContext.create(credentials));
result.saveAs("output/extractPdf.zip");
| Modifier and Type | Method and Description |
|---|---|
static ExtractPDFOperation |
createNew()
Constructs a
ExtractPDFOperation instance. |
FileRef |
execute(ExecutionContext context)
Executes this operation synchronously using the supplied context and returns a new FileRef instance for the resulting Zip file.
|
ExtractPDFOperation |
setInputFile(FileRef sourceFileRef)
Sets an input file.
|
ExtractPDFOperation |
setOptions(ExtractPDFOptions extractPDFOptions)
Sets the options for this operation.
|
public static ExtractPDFOperation createNew()
ExtractPDFOperation instance.ExtractPDFOperation instancepublic ExtractPDFOperation setOptions(ExtractPDFOptions extractPDFOptions)
ExtractPDFOptions for how to specify the
options for the different elements and renditions.extractPDFOptions - optionExtractPDFOperation instancepublic ExtractPDFOperation setInputFile(FileRef sourceFileRef)
sourceFileRef - an input fileExtractPDFOperation instancepublic 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 Operationcontext - 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 Zip fileServiceUsageException - if service usage limits have been reached or credentials quota has been exhausted.Copyright © 2022 Adobe. All rights reserved.