Class ExportPDFToImagesJob


  • public class ExportPDFToImagesJob
    extends PDFServicesJob
    A job which exports a source PDF file to a supported format specified by ExportPDFToImagesTargetFormat.

    The result is a list of images or a list containing a zip of images. For example, a PDF file with 15 pages will generate 15 image files. The first file's name ends with "_0" and the last file's name ends with "_14".

    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());
    
                 ExportPDFToImagesParams exportPDFToImagesParams = ExportPDFToImagesParams.exportPDFToImagesParamsBuilder(
                                 ExportPDFToImagesTargetFormat.JPEG, ExportPDFToImagesOutputType.LIST_OF_PAGE_IMAGES).build();
                 ExportPDFToImagesJob exportPDFToImagesJob = new ExportPDFToImagesJob(asset, exportPDFToImagesParams);
    
                 String location = pdfServices.submit(exportPDFToImagesJob);
                 PDFServicesResponse<ExportPDFToImagesResult> pdfServicesResponse = pdfServices.getJobResult(location, ExportPDFToImagesResult.class);
    
                 List<Asset> resultAssets = pdfServicesResponse.getResult().getAssets();
    
                 int index = 0;
                 for (Asset resultAsset : resultAssets) {
                     StreamAsset streamAsset = pdfServices.getContent(resultAsset);
                     index++;
                 }
     
    • Constructor Detail

      • ExportPDFToImagesJob

        public ExportPDFToImagesJob​(Asset asset,
                                    ExportPDFToImagesParams exportPDFToImagesParams)
        Constructs a new ExportPDFToImagesJob instance.
        Parameters:
        asset - Asset object containing the input file; can not be null.
        exportPDFToImagesParams - ExportPDFToImagesParams object containing the export to images parameters; can not be null.
    • Method Detail

      • setOutput

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