This project provides a set of utilities for converting various file formats without the need for additional dependencies. It supports multiple file types and leverages technologies like Playwright, PDFKit, and pdfjs-dist for file processing.
Features
HTML to PDF: Converts HTML content (from a URL or file path) into a PDF.
Image to PDF: Converts images (JPEG, PNG) into a PDF, with optional headers and footers.
PDF to Image: Converts PDF files to image formats (JPEG or PNG) using pdfjs-dist and canvas.
Utilities: Includes helper functions to fetch and read HTML files and read files from local directories.
Requirements
Node.js: This project is built with Node.js and uses ES modules. NodeJS > v22 required.
Operations Available in the Package
1. html2pdf
Function Signature:
html2pdf(input:string|URL)
Parameters:
Parameter
Type
Description
Data that can be passed
input
string | URL
The HTML content to convert to PDF.
A file path or a URL pointing to HTML content, as either a Node URL object or a Node string. Alternativly pass an html string directly.