UNPKG

chromiumly

Version:

A lightweight Typescript library that interacts with Gotenberg's different modules to convert a variety of document formats to PDF files.

47 lines (46 loc) 3.73 kB
import { HtmlConversionOptions } from '../interfaces/converter.types'; import { Converter } from './converter'; /** * Class representing an HTML converter that extends the base Converter class. * This class is used to convert HTML content to PDF using Gotenberg service. * * @extends Converter */ export declare class HtmlConverter extends Converter { /** * Creates an instance of HtmlConverter. * Initializes the converter with the HTML conversion route. */ constructor(); /** * Converts HTML content to PDF. * * @param {Object} options - Conversion options. * @param {PathLikeOrReadStream} options.html - PathLike or ReadStream of the HTML content to be converted. * @param {PathLikeOrReadStream} [options.header] - PathLike or ReadStream of the header HTML content. * @param {PathLikeOrReadStream} [options.footer] - PathLike or ReadStream of the footer HTML content. * @param {PageProperties} [options.properties] - Page properties for the conversion. * @param {PdfFormat} [options.pdfFormat] - PDF format options. * @param {boolean} [options.pdfUA] - Indicates whether to generate PDF/UA compliant output. * @param {EmulatedMediaType} [options.emulatedMediaType] - Emulated media type for the conversion. * @param {EmulatedMediaFeature[]} [options.emulatedMediaFeatures] - Override CSS media features (e.g. prefers-color-scheme). * @param {string} [options.waitDelay] - Delay before the conversion process starts. * @param {string} [options.waitForExpression] - JavaScript expression to wait for before completing the conversion. * @param {string} [options.waitForSelector] - CSS selector to wait for before completing the conversion. * @param {string} [options.userAgent] - User agent string to use during the conversion. * @param {Record<string, string>} [options.extraHttpHeaders] - Additional HTTP headers for the conversion. * @param {number[]} [options.failOnHttpStatusCodes] - Whether to fail on HTTP status code. * @param {boolean} [options.failOnConsoleExceptions] - Whether to fail on console exceptions during conversion. * @param {number[]} [options.failOnResourceHttpStatusCodes] - Whether to fail on resource HTTP status code. * @param {string[]} [options.ignoreResourceHttpStatusDomains] - Domains to exclude from resource HTTP status code checks. * @param {boolean} [options.failOnResourceLoadingFailed] - Whether to fail on resource loading failed. * @param {boolean} [options.skipNetworkIdleEvent] - Whether to skip network idle event. * @param {boolean} [options.generateDocumentOutline] - Whether to generate document outline. * @param {Metadata} options.metadata - Metadata to be written. * @param {Cookie[]} options.cookies - Cookies to be written. * @param {DownloadFrom} [options.downloadFrom] - Download a file from a URL. It must return a Content-Disposition header with a filename parameter. * @param {Split} [options.split] - Split the PDF into multiple files. * @returns {Promise<Buffer>} A Promise resolving to the converted PDF content as a buffer */ convert({ html, assets, header, footer, properties, pdfFormat, pdfUA, emulatedMediaType, emulatedMediaFeatures, waitDelay, waitForExpression, waitForSelector, userAgent, extraHttpHeaders, failOnHttpStatusCodes, failOnConsoleExceptions, failOnResourceHttpStatusCodes, ignoreResourceHttpStatusDomains, failOnResourceLoadingFailed, skipNetworkIdleEvent, skipNetworkAlmostIdleEvent, generateDocumentOutline, metadata, cookies, downloadFrom, webhook, split, userPassword, ownerPassword, embeds, watermark, stamp, rotate }: HtmlConversionOptions): Promise<Buffer>; }