Class ExportPDFJob


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

    For example, a PDF can be exported to a DOCX file as follows:

    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());
    
                 ExportPDFParams exportPDFParams = ExportPDFParams.exportPDFParamsBuilder(ExportPDFTargetFormat.DOCX).build();
                 ExportPDFJob exportPDFJob = new ExportPDFJob(asset, exportPDFParams);
    
                 String location = pdfServices.submit(exportPDFJob);
                 PDFServicesResponse<ExportPDFResult> pdfServicesResponse = pdfServices.getJobResult(location, ExportPDFResult.class);
    
                 Asset resultAsset = pdfServicesResponse.getResult().getAsset();
                 StreamAsset result = pdfServices.getContent(resultAsset);
     
    • Constructor Detail

      • ExportPDFJob

        public ExportPDFJob​(Asset asset,
                            ExportPDFParams exportPDFParams)
        Constructs a new ExportPDFJob instance.
        Parameters:
        asset - Asset object containing the input file; can not be null.
        exportPDFParams - ExportPDFParams object containing the export parameters; can not be null.
    • Method Detail

      • setOutput

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