Class DeletePagesJob


  • public class DeletePagesJob
    extends PDFServicesJob
    A job to delete pages in a PDF file.

    Sample Usage:

    
                 InputStream inputStream = new FileInputStream(new File("SOURCE_PATH"));
    
                 Credentials credentials = new ServicePrincipalCredentials(
                         System.getenv("PDF_SERVICES_CLIENT_ID"),
                         System.getenv("PDF_SERVICES_CLIENT_SECRET"));
    
                 PDFServices pdfServices = new PDFServices(credentials);
    
                 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
    
                 PageRanges pageRangeForDeletion = new PageRanges();
                 pageRangeForDeletion.addSinglePage(1);
                 DeletePagesParams deletePagesParams = new DeletePagesParams(pageRangeForDeletion);
                 DeletePagesJob deletePagesJob = new DeletePagesJob(asset, deletePagesParams);
    
                 String location = pdfServices.submit(deletePagesJob);
                 PDFServicesResponse<DeletePagesResult> pdfServicesResponse = pdfServices.getJobResult(location, DeletePagesResult.class);
    
                 Asset deletePagesResult = pdfServicesResponse.getResult().getAsset();
                 StreamAsset streamAsset = pdfServices.getContent(deletePagesResult);
     
    • Constructor Detail

      • DeletePagesJob

        public DeletePagesJob​(Asset asset,
                              DeletePagesParams deletePagesParams)
        Constructs a new DeletePagesJob instance.
        Parameters:
        asset - Asset object containing the input file; can not be null.
        deletePagesParams - DeletePagesParams object containing the page ranges to be deleted; can not be null.
    • Method Detail

      • setOutput

        public DeletePagesJob setOutput​(Asset asset)
        Sets the output asset for the job. @note External assets can be set as output only when input is external asset as well
        Parameters:
        asset - Asset object representing the output asset; can not be null.
        Returns:
        DeletePagesJob instance