JSPM

@myunisoft/html-to-pdf

1.3.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q34894F
  • License MIT

Node lib for converts HTML with dynamic or static content or url to PDF files

Package Exports

  • @myunisoft/html-to-pdf
  • @myunisoft/html-to-pdf/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@myunisoft/html-to-pdf) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

HTMLToPDF

Node lib to converts HTML with property binding or url to PDF files

Installation

$ npm install @myunisoft/html-to-pdf

Unit Test

  • Jest
  • Coverage : 100%

Usage

async function main() {
  const browser = await initBrowser();

  try {
    const { pdfs } = await generatePDF(browser, files);
    const { pdf } = await generatePDF(browser, file);

    const stream = fs.createWriteStream(`./${your_pdf_name}.pdf`);

    stream.write(pdf.buffer); // => create file for the given buffer.
    
    for (let pdf of pdfs) {
      stream.write(pdf.buffer); // => create file for each given buffer
    }
  }
  finally {
    await terminateBrowser(browser);
  }
}

main().catch(console.error);

initBrowser(): Promise

async function main() {
  const browser = await initBrowser();
}
main().catch(console.error);

generatePDF(browser: Browser, files: pdfFile[], options?: PDFOPtions): Promise

interface pdfFile {
  content?: string,
  url?: string
}
async function main() {
  const browser = await initBrowser();
  const result = Readable.from(generatePDF(browser, [{ content: html.content }], pdfOptions ?? kDefaultOptions));
}
main().catch(console.error);

terminateBrowser(browser: Browser): Promise

async function main() {
  const browser = await pdf.initBrowser();
  await terminateBrowser(browser);
}
main().catch(console.error);