Class CreatePDFJob


  • public class CreatePDFJob
    extends PDFServicesJob
    A job that converts a non-PDF file to a PDF file. Some source formats may have associated conversion parameters which can be set in the setParams(CreatePDFParams) method.

    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.DOCX.getMediaType());
    
                 CreatePDFJob createPDFJob = new CreatePDFJob(asset);
    
                 String location = pdfServices.submit(createPDFJob);
                 PDFServicesResponse<CreatePDFResult> pdfServicesResponse = pdfServices.getJobResult(location, CreatePDFResult.class);
    
                 Asset resultAsset = pdfServicesResponse.getResult().getAsset();
                 StreamAsset streamAsset = pdfServices.getContent(resultAsset);
     
    • Constructor Detail

      • CreatePDFJob

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

      • setParams

        public CreatePDFJob setParams​(CreatePDFParams createPDFParams)
        Sets the conversion parameters for this job. See CreatePDFJob for how to specify the conversion parameters for the different source media types.
        Parameters:
        createPDFParams - CreatePDFParams; can not be null.
        Returns:
        CreatePDFJob instance
      • setOutput

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