public class ReorderPagesOperation extends Object implements Operation
Sample Usage:
ReorderPagesOperation reorderPagesOperation = ReorderPagesOperation.createNew();
reorderPagesOperation.setInput(FileRef.createFromLocalFile("~/Documents/reorderPagesOperationInput.pdf",
ReorderPagesOperation.SupportedSourceFormat.PDF.getMediaType()));
PageRanges pageRanges = new PageRanges();
pageRanges.addSinglePage(3);
pageRanges.addRange(1,2);
reorderPagesOperation.setPagesOrder(pageRanges);
Credentials credentials = Credentials.serviceAccountCredentialsBuilder().fromFile("pdftools-api-credentials.json").build();
FileRef result = reorderPagesOperation.execute(ExecutionContext.create(credentials));
result.saveAs("output/reorderPagesOperationOutput.pdf");
Modifier and Type | Class and Description |
---|---|
static class |
ReorderPagesOperation.SupportedSourceFormat
Supported source file formats for
ReorderPagesOperation . |
Modifier and Type | Method and Description |
---|---|
static ReorderPagesOperation |
createNew()
Constructs a
ReorderPagesOperation instance. |
FileRef |
execute(ExecutionContext context)
Executes this operation synchronously using the supplied context and returns a new FileRef instance for the resulting PDF file.
|
void |
setInput(FileRef sourceFileRef)
Sets an input file.
|
void |
setPagesOrder(PageRanges pageRanges)
Sets the order of the pages.
|
public static ReorderPagesOperation createNew()
ReorderPagesOperation
instance.ReorderPagesOperation
instancepublic void setInput(FileRef sourceFileRef)
sourceFileRef
- an input file; can not be nullpublic void setPagesOrder(PageRanges pageRanges)
pageRanges
- page ranges for reordering; can not be null or emptypublic 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 PDF fileServiceUsageException
- if service usage limits have been reached or credentials quota has been exhaustedCopyright © 2020 Adobe. All rights reserved.