public class SplitPDFOperation extends Object implements Operation
Sample Usage:
SplitPDFOperation splitPDFOperation = SplitPDFOperation.createNew();
splitPDFOperation.setInput(FileRef.createFromLocalFile("~/Documents/splitPDFOperationInput.pdf",
SplitPDFOperation.SupportedSourceFormat.PDF.getMediaType()));
splitPDFOperation.setPageCount(2);
Credentials credentials = Credentials.serviceAccountCredentialsBuilder().fromFile("pdfservices-api-credentials.json").build();
List<FileRef> result = splitPDFOperation.execute(ExecutionContext.create(credentials));
int index = 0;
for (FileRef fileRef : result) {
fileRef.saveAs("output/splitPDFOperationOutput_" + index + ".pdf");
index++;
}
Modifier and Type | Class and Description |
---|---|
static class |
SplitPDFOperation.SupportedSourceFormat
Supported source file formats for
SplitPDFOperation . |
Modifier and Type | Method and Description |
---|---|
static SplitPDFOperation |
createNew()
Constructs a
SplitPDFOperation 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 PDF files.
|
void |
setFileCount(int fileCount)
Sets the number of documents to split the input PDF.
|
void |
setInput(FileRef sourceFileRef)
Sets an input file.
|
void |
setPageCount(int pageCount)
Sets the maximum number of pages each of the output files can have.
|
void |
setPageRanges(PageRanges pageRanges)
Sets the page ranges on the basis of which to split the input PDF file.
|
public static SplitPDFOperation createNew()
SplitPDFOperation
instance.SplitPDFOperation
instancepublic void setInput(FileRef sourceFileRef)
sourceFileRef
- an input file; can not be nullpublic void setPageRanges(PageRanges pageRanges)
pageRanges
- page ranges for split; can not be null or emptypublic void setPageCount(int pageCount)
pageCount
- maximum number of pages per output filepublic void setFileCount(int fileCount)
fileCount
- represents the number of output filespublic 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 PDF fileServiceUsageException
- if service usage limits have been reached or credentials quota has been exhaustedCopyright © 2022 Adobe. All rights reserved.