A job that converts a HTML file to a PDF file. Some source formats may have associated conversion parameters which can be set using the HTMLToPDFParams parameter.

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:

html_files.zip
|__index.html
|__referenced_file_1.css
|__referenced_file_2.jpeg
|__subfolder_1
|_____referenced_file_3.jpeg

Example

Sample Usage:

        const credentials = new ServicePrincipalCredentials({
clientId: process.env.PDF_SERVICES_CLIENT_ID,
clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET
});

const pdfServices = new PDFServices({credentials});

const job = new HTMLToPDFJob({inputURL: "<HTML URL>"});

const pollingURL = await pdfServices.submit({job});

const pdfServicesResponse = await pdfServices.getJobResult({
pollingURL,
resultType: HTMLToPDFResult
});

const resultAsset = pdfServicesResponse.result.asset;
const streamAsset = await pdfServices.getContent({asset: resultAsset});

Hierarchy (view full)

Constructors

  • Constructs a new HTMLToPDFJob instance.

    Parameters

    • params: {
          inputAsset?: Asset;
          inputURL?: string;
          outputAsset?: Asset;
          params?: HTMLToPDFParams;
      }

      The parameters for constructing an instance of HTMLToPDFJob.

      • Optional inputAsset?: Asset

        Asset object containing the input file.

      • Optional inputURL?: string

        The URL of the input HTML file.

      • Optional outputAsset?: Asset

        Asset object representing the output asset.

      • Optional params?: HTMLToPDFParams

        HTMLToPDFParams object containing the HTML to PDF conversion parameters.

    Returns HTMLToPDFJob

    Remarks

    External assets can be set as output only when input is external asset as well.

Properties

_htmlToPDFParams?: HTMLToPDFParams
_inputAsset?: Asset
_inputURL?: string
_outputAsset?: Asset

Methods

  • Parameters

    Returns PDFServicesApiRequest

  • Parameters

    • executionContext: ExecutionContext

    Returns void

Generated using TypeDoc