Class CompressPDFJob

  • public class CompressPDFJob
    extends PDFServicesJob
    A job that reduces the size of a PDF file. Allows specifying compressionLevel(CompressionLevel) for compressing pdf

    Sample Usage:

                 InputStream inputStream = new FileInputStream(new File("SOURCE_PATH"));
                 Credentials credentials = new ServicePrincipalCredentials(
                 PDFServices pdfServices = new PDFServices(credentials);
                 Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
                 CompressPDFJob compressPDFJob = new CompressPDFJob(asset);
                 String location = pdfServices.submit(compressPDFJob);
                 PDFServicesResponse<CompressPDFResult> pdfServicesResponse = pdfServices.getJobResult(location, CompressPDFResult.class);
                 Asset compressedPDFAsset = pdfServicesResponse.getResult().getAsset();
                 StreamAsset compressedPDFStreamAsset = pdfServices.getContent(compressedPDFAsset);
    • Constructor Detail

      • CompressPDFJob

        public CompressPDFJob​(Asset asset)
        Constructs a new CompressPDFJob instance.
        asset - Asset object containing the input file; can not be null.
    • Method Detail

      • setParams

        public CompressPDFJob setParams​(CompressPDFParams compressPDFParams)
        Sets the compression level for the input PDF file.
        compressPDFParams - CompressPDFParams object containing the compression level; can not be null.
        CompressPDFJob instance
      • setOutput

        public CompressPDFJob 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
        asset - Asset object representing the output asset; can not be null.
        CompressPDFJob instance