@xavorus/html-to-pdf-cli
v1.0.1
Published
Convert local HTML files to PDF using Puppeteer
Maintainers
Readme
#html-to-pdf - Simple HTML to PDF CLI 📄
Lightweight CLI tool for converting local HTML files to PDF with Puppeteer. Suitable for CVs, portfolios, or static reports.
✨ Features
🧾 Flexible Conversion Supports a single HTML file or folder.
📐 Layout Control Set paper format, margins, and orientation (landscape/portrait).
🧩 Header & Footer Simple HTML templates for headers/footers in PDFs.
🚀 Installation
Global (for CLI):
npm install -g @xavorus/html-to-pdf-cli💻 Usage Examples
Convert a single file (automatic output to .pdf):
html-to-pdf ./resume.htmlOutput to a specific file:
html-to-pdf ./resume.html ./resume.pdfConvert all HTML in a folder to an output folder:
html-to-pdf ./input_html ./output_pdfConvert only specific files in a folder:
html-to-pdf ./input_html ./output_pdf --only "resume.html,portfolio.html"Letter + landscape format:
html-to-pdf ./resume.html ./resume.pdf --letter format --landscapeSimple header/footer:
html-to-pdf ./resume.html ./resume.pdf \
--header "<div style='font-size:9px;'>CV - Page <span class='pageNumber'></span></div>" \
--footer "<div style='font-size:9px; text-align:right;'>Caption</div>"⚙️ Command Options
| Options | Description |
| ----------------- | ------------------------------------------------------------- |
| --input | Input file/folder path (optional, can be positional). |
| --output | Output file/folder path (optional, can be positional). |
| --only | List of selected file names, separated by commas. |
| --format | Paper format, e.g., A4, Letter. |
| --landscape | Landscape mode. |
| --margin-top | Top margin (default 10mm). |
| --margin-right | Right margin (default 10mm). |
| --margin-bottom | Bottom margin (default 10mm). |
| --margin-left | Left margin (default 10mm). |
| --header | HTML string for the header. |
| --footer | HTML string for the footer. |
📦 Sample Output
Success:
PDF saved: D:\Project\html_to_pdf\RESUME_KwikAndreasJonathan.pdfBatch folders:
PDF saved: D:\Project\html_to_pdf\output_pdf\CV_KwikAndreasJonathanAbandonded.pdf
PDF saved: D:\Project\html_to_pdf\output_pdf\PORTOFOLIO_KwiKAndreasJonathan.pdf🤝 Contributing
- Fork this repository
- Create a feature branch
- Commit your changes
- Push the branch
- Open Pull Request
📄 License
MIT License. See LICENSE file for details.
