public class CombineFilesOperation extends Object implements Operation
Sample Usage:
CombineFilesOperation combineFilesOperation = CombineFilesOperation.createNew();
combineFilesOperation.addInput(FileRef.createFromLocalFile("~/Documents/combinePdfInput1.pdf",
CombineFilesOperation.SupportedSourceFormat.PDF.getMediaType()));
combineFilesOperation.addInput(FileRef.createFromLocalFile("~/Documents/combinePdfInput2.pdf",
CombineFilesOperation.SupportedSourceFormat.PDF.getMediaType()));
Credentials credentials = Credentials.serviceAccountCredentialsBuilder().fromFile("pdfservices-api-credentials.json").build();
FileRef result = combineFilesOperation.execute(ExecutionContext.create(credentials));
result.saveAs("output/CombineFilesOutput.pdf");
Modifier and Type | Class and Description |
---|---|
static class |
CombineFilesOperation.SupportedSourceFormat
Supported source file formats for
CombineFilesOperation . |
Modifier and Type | Method and Description |
---|---|
void |
addInput(FileRef sourceFileRef)
Specifies a PDF file (media type "application/pdf") to be combined with other files.
|
void |
addInput(FileRef sourceFileRef,
PageRanges pageRanges)
Specifies particular pages of a PDF file (media type "application/pdf") to be combined with other files.
|
static CombineFilesOperation |
createNew()
Constructs a
CombineFilesOperation instance. |
FileRef |
execute(ExecutionContext context)
Executes this operation synchronously using the supplied context and returns a new FileRef instance for the resulting file.
|
public static CombineFilesOperation createNew()
CombineFilesOperation
instance.CombineFilesOperation
instancepublic void addInput(FileRef sourceFileRef)
For adding particular pages of a PDF file, use addInput(FileRef, PageRanges)
.
sourceFileRef
- a PDF file to be combinedpublic void addInput(FileRef sourceFileRef, PageRanges pageRanges)
For adding all the pages of the file, consider addInput(FileRef)
.
sourceFileRef
- a PDF filepageRanges
- page ranges of the PDF file to be combinedpublic 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 © 2022 Adobe. All rights reserved.