Class SplitPDFJob


  • public class SplitPDFJob
    extends PDFServicesJob
    A job that splits PDF document into multiple smaller documents by simply specifying either the number of files, pages per file, or page ranges.

    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());
    
                 SplitPDFParams splitPDFParams = new SplitPDFParams().setPageCount(2);
                 SplitPDFJob splitPDFJob = new SplitPDFJob(asset, splitPDFParams);
    
                 String location = pdfServices.submit(splitPDFJob);
                 PDFServicesResponse<SplitPDFResult> pdfServicesResponse = pdfServices.getJobResult(location, SplitPDFResult.class);
    
                 List<Asset> resultAssets = pdfServicesResponse.getResult().getAssets();
    
                 int index = 0;
                 for (Asset resultAsset : resultAssets) {
                     StreamAsset streamAsset = pdfServices.getContent(resultAsset);
                     index++;
                 }
     
    • Constructor Detail

      • SplitPDFJob

        public SplitPDFJob​(Asset asset,
                           SplitPDFParams splitPDFParams)
        Constructs a new SplitPDFJob instance.
        Parameters:
        asset - Asset object containing the input file; can not be null.
        splitPDFParams - SplitPDFParams object containing the parameters for splitting the PDF; can not be null.
    • Method Detail

      • setOutput

        public SplitPDFJob 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:
        SplitPDFJob instance