UNPKG

@ironsoftware/ironpdf

Version:

IronPDF for Node

81 lines 4.03 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PdfGenerator = void 0; const pdfDocument_1 = require("./pdfDocument"); /** * A utility class to create a new {@link PdfDocument} object */ class PdfGenerator { /** * Creates a PDF file from a Html string, and returns it as an {@link PdfDocument} object which can be edited and saved to disk or served on a website. * @param htmlStringOrHtmlFilePath The Html to be rendered as a PDF. * @param options including {@link ChromePdfRenderOptions} */ static htmlToPdf(htmlStringOrHtmlFilePath, options) { return __awaiter(this, void 0, void 0, function* () { return pdfDocument_1.PdfDocument.fromHtml(htmlStringOrHtmlFilePath, options); }); } /** * Create a PdfDocument from an Url * @param url A website Url * @param options including {@link ChromePdfRenderOptions} */ static urlToPdf(url, options) { return __awaiter(this, void 0, void 0, function* () { return pdfDocument_1.PdfDocument.fromUrl(url, options); }); } /** * Creates a PDF file from a local Zip file, and returns it as a {@link PdfDocument}. * IronPDF is a W3C standards compliant HTML rendering based on Google's Chromium browser. * If your output PDF does not look as expected: * * - Validate your HTML file using https://validator.w3.org/ & CSS https://jigsaw.w3.org/css-validator/ * * - To debug HTML, view the file in Chrome web browser's print preview which will work almost exactly as IronPDF. * * - Read our detailed documentation on pixel perfect HTML to PDF: https://ironpdf.com/tutorials/pixel-perfect-html-to-pdf/ * * @param zipFilePath Path to a Zip to be rendered as a PDF. * @param options including {@link ChromePdfRenderOptions} and `mainHtmlFile` a main .html file default: `index.html` */ static htmlZipFileToPdf(zipFilePath, options) { return __awaiter(this, void 0, void 0, function* () { return pdfDocument_1.PdfDocument.fromZip(zipFilePath, options); }); } /** * Converts multiple image files to a PDF document. Each image creates 1 page which matches the image * dimensions. The default PaperSize is A4. You can set it via ImageToPdfConverter.PaperSize. * Note: Imaging.ImageBehavior.CropPage will set PaperSize equal to ImageSize. * @param images The image file path name(s) or {@link ImageBuffer} object(s) * @param options including {@link ImageToPdfOptions} */ static imageToPdf(images, options) { return __awaiter(this, void 0, void 0, function* () { return pdfDocument_1.PdfDocument.fromImage(images, options); }); } /** * Static method that joins (concatenates) multiple PDF documents together into one compiled PDF document. * If the PDF contains form fields the form field in the resulting PDF's name will be appended with '_{index}' e.g. 'Name' will be 'Name_0' * @param pdfs array of PDF */ static mergePdf(pdfs) { return __awaiter(this, void 0, void 0, function* () { return pdfDocument_1.PdfDocument.mergePdf(pdfs); }); } } exports.PdfGenerator = PdfGenerator; //# sourceMappingURL=pdfGenerator.js.map