@benpley/wappler-html2pdf
v1.0.4
Published
Convert HTML to PDF using headless Chrome in Wappler Server Connect
Maintainers
Readme
HTML to PDF Server Connect Module
This module enables converting HTML content to PDF files server-side within your Wappler NodeJS projects, powered by Puppeteer. It is suitable for generating documents, reports, invoices, or any printable content in PDF format.
Features
- Convert any HTML content to a PDF file
- Many configuration options for PDF output
- Page size, margin, landscape/portrait, and background print control
- Header and footer templates
- Wait-for-selector and timing options for dynamic content
- Save output to a file (custom path or temp) or use for immediate download
Configuration Options
The module supports the following settings:
HTML Content
- html (required): The HTML string to be converted into PDF
PDF Output
- filename: Set a filename for the PDF (default:
document.pdf) - path: Set a save path for the PDF file (optional)
Page Settings
- format: Page format (
A4,A3,A5,Letter,Legal,Tabloid) (default:A4) - landscape: Use landscape orientation (default:
false) - printBackground: Print background graphics (default:
true) - scale: Webpage rendering scale (0.1 to 2; default:
1)
Margins
- marginTop, marginRight, marginBottom, marginLeft: Set page margins (e.g.,
10mm,1in)
Header and Footer
- displayHeaderFooter: Toggle header/footer rendering
- headerTemplate: HTML template for the header
- footerTemplate: HTML template for the footer
Advanced
- preferCSSPageSize: Use CSS page size if defined
- waitForSelector: Wait for a CSS selector before generating PDF (optional)
- waitTime: Wait additional ms before PDF generation (default:
0)
For all options, both static values and server data bindings are supported.
Dependency
The module uses the Puppeteer Node package. Make sure it is installed (version ^22.0.0).
Usage
- Add the HTML to PDF step in your Server Connect workflow.
- Configure required and optional properties as above.
- Trigger your Server Connect API from your frontend to generate/download the PDF.
Example Use Case
Generate an invoice or report from your dynamic HTML content and either serve it for download or save it to a folder (e.g., uploads/pdfs/invoice.pdf).
Issues and Support
For bug reports, feature requests, or assistance, please use the Wappler Community Forum.
Second release. Feedback welcome!
