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

    An HTML input can be provided either as a local zip archive or as a static HTML file with inline CSS. Alternatively, an HTML can also be specified via URL.
    While creating the corresponding Asset instance, the media type must be:

    • "application/zip", if the input is a local zip archive.
    • "text/html", if the input is a static HTML file with inline CSS

    In case the input is a local zip archive, it must have the following structure:
    • The main HTML file must be named "index.html".
    • "index.html" must exist at the top level of zip archive, not in a folder.

    Sample layout:

    Sample Usage:

                 InputStream inputStream = new FileInputStream(new File("SOURCE_PATH"));
                 Credentials credentials = new ServicePrincipalCredentials(
                 PDFServices pdfServices = new PDFServices(credentials);
                 HTMLToPDFJob htmLtoPDFJob = new HTMLToPDFJob("URL");
                 String location = pdfServices.submit(htmLtoPDFJob);
                 PDFServicesResponse<HTMLtoPDFResult> pdfServicesResponse = pdfServices.getJobResult(location, HTMLtoPDFResult.class);
                 Asset resultAsset = pdfServicesResponse.getResult().getAsset();
                 StreamAsset streamAsset = pdfServices.getContent(resultAsset);
    • Constructor Detail

      • HTMLToPDFJob

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

        public HTMLToPDFJob​(String inputURL)
        Constructs a new HTMLToPDFJob instance.
        inputURL - string representing the input URL; can not be null.
    • Method Detail

      • setParams

        public HTMLToPDFJob setParams​(HTMLToPDFParams htmLtoPDFParams)
        Sets the HTML to PDF conversion parameters.
        htmLtoPDFParams - HTMLToPDFParams; can not be null.
        HTMLToPDFJob instance
      • setOutput

        public HTMLToPDFJob 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.
        HTMLToPDFJob instance