UNPKG

@adobe/pdfservices-node-sdk

Version:

The Adobe PDF Services Node.js SDK provides APIs for creating, combining, exporting and manipulating PDFs.

88 lines (87 loc) 3.25 kB
import { PDFServicesJob } from "./PDFServicesJob"; import { Asset } from "../../io/Asset"; import { HTMLToPDFParams } from "../params/htmltopdf/HTMLToPDFParams"; import { ExecutionContext } from "../../internal/ExecutionContext"; import { NotifierConfig } from "../../config/notifier/NotifierConfig"; /** * 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 {@link HTMLToPDFParams} parameter. * * * <p> * 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. * <br> * While creating the corresponding Asset instance, the media type must be: * <ul> * <li>"application/zip", if the input is a local zip archive.</li> * <li>"text/html", if the input is a static HTML file with inline CSS</li> * </ul> * <br> * In case the input is a local zip archive, it must have the following structure: * <ul> * <li>The main HTML file must be named "index.html".</li> * <li>"index.html" must exist at the top level of zip archive, not in a folder.</li> * </ul> * <p> * Sample layout:<pre> * html_files.zip * |__index.html * |__referenced_file_1.css * |__referenced_file_2.jpeg * |__subfolder_1 * |_____referenced_file_3.jpeg * </pre> * * <p> * * @example * Sample Usage: * ```js * 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}); * ``` */ export declare class HTMLToPDFJob extends PDFServicesJob { private readonly _inputAsset?; private readonly _inputURL?; private readonly _outputAsset?; private readonly _htmlToPDFParams?; /** * Constructs a new `HTMLToPDFJob` instance. * * @param params The parameters for constructing an instance of `HTMLToPDFJob`. * @param [params.inputAsset] {@link Asset} object containing the input file. * @param [params.inputURL] The URL of the input HTML file. * @param [params.outputAsset] {@link Asset} object representing the output asset. * @param [params.params] {@link HTMLToPDFParams} object containing the HTML to PDF conversion parameters. * @remarks External assets can be set as output only when input is external asset as well. */ constructor(params: { inputAsset?: Asset; inputURL?: string; outputAsset?: Asset; params?: HTMLToPDFParams; }); /** * @hidden */ process(executionContext: ExecutionContext, notifierConfigList?: NotifierConfig[]): Promise<string>; private generatePDFServicesAPIRequest; }