public class ReplacePagesOperation extends Object implements Operation
 For more complex use cases, refer the CombineFilesOperation.
 
Sample Usage:
   ReplacePagesOperation replacePagesOperation = ReplacePagesOperation.createNew();
   replacePagesOperation.setBaseInput(FileRef.createFromLocalFile("~/Documents/replacePagesOperationBaseInput.pdf",
                                                             ReplacePagesOperation.SupportedSourceFormat.PDF.getMediaType()));
   replacePagesOperation.addPagesForReplace(FileRef.createFromLocalFile("~/Documents/replacePagesOperationFileToBeReplacedWithInput.pdf",
                                                             ReplacePagesOperation.SupportedSourceFormat.PDF.getMediaType()), 1);
   Credentials credentials = Credentials.serviceAccountCredentialsBuilder().fromFile("pdftools-api-credentials.json").build();
   FileRef result = replacePagesOperation.execute(ExecutionContext.create(credentials));
   result.saveAs("output/replacePagesOperationOutput.pdf");
 | Modifier and Type | Class and Description | 
|---|---|
static class  | 
ReplacePagesOperation.SupportedSourceFormat
Supported source file formats for  
ReplacePagesOperation. | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addPagesForReplace(FileRef inputFile,
                  int basePageToReplace)
Adds all the pages of the input PDF file for replacing the page of the base PDF file. 
 | 
void | 
addPagesForReplace(FileRef inputFile,
                  PageRanges pageRanges,
                  int basePageToReplace)
Adds the specified pages of the input PDF file for replacing the page of the base PDF file. 
 | 
static ReplacePagesOperation | 
createNew()
Constructs a  
ReplacePagesOperation 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 | 
setBaseInput(FileRef sourceFileRef)
Sets the base input file. 
 | 
public static ReplacePagesOperation createNew()
ReplacePagesOperation instance.ReplacePagesOperation instancepublic void setBaseInput(FileRef sourceFileRef)
sourceFileRef - the base input file; can not be nullpublic void addPagesForReplace(FileRef inputFile, int basePageToReplace)
This method can be invoked multiple times with the same or different input PDF files.
inputFile - a PDF file to be replaced with; can not be nullbasePageToReplace - page of base PDF filepublic void addPagesForReplace(FileRef inputFile, PageRanges pageRanges, int basePageToReplace)
This method can be invoked multiple times with the same or different input PDF files.
inputFile - a PDF file to be replaced with; can not be nullpageRanges - page ranges of the input PDF filebasePageToReplace - page of base PDF filepublic 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 PDF fileServiceUsageException - if service usage limits have been reached or credentials quota has been exhaustedCopyright © 2020 Adobe. All rights reserved.