chuongtrh / Html_to_pdf
Generate a simple invoice PDF from HTML using puppeteer & handlebars
Stars: ✭ 62
Projects that are alternatives of or similar to Html to pdf
Asciidoctor Web Pdf
Convert AsciiDoc documents to PDF using web technologies
Stars: ✭ 219 (+253.23%)
Mutual labels: pdf, puppeteer
Puppeteer Dart
A Dart library to automate the Chrome browser over the DevTools Protocol. This is a port of the Puppeteer API
Stars: ✭ 92 (+48.39%)
Mutual labels: pdf, puppeteer
Gotenberg
A Docker-powered stateless API for PDF files.
Stars: ✭ 3,272 (+5177.42%)
Mutual labels: pdf, puppeteer
Tea School
Simplified HTML + CSS --> PDF Generator for Nodejs
Stars: ✭ 326 (+425.81%)
Mutual labels: pdf, puppeteer
Puppetron
Puppeteer (Headless Chrome Node API)-based rendering solution.
Stars: ✭ 429 (+591.94%)
Mutual labels: pdf, puppeteer
Educative.io Downloader
📖 This tool is to download course from educative.io for offline usage. It uses your login credentials and download the course.
Stars: ✭ 139 (+124.19%)
Mutual labels: pdf, puppeteer
Cloud Reports
Scans your AWS cloud resources and generates reports. Check out free hosted version:
Stars: ✭ 255 (+311.29%)
Mutual labels: pdf, puppeteer
Percollate
A command-line tool to turn web pages into beautiful, readable PDF, EPUB, or HTML docs.
Stars: ✭ 3,535 (+5601.61%)
Mutual labels: pdf, puppeteer
Md To Pdf
Hackable CLI tool for converting Markdown files to PDF using Node.js and headless Chrome.
Stars: ✭ 374 (+503.23%)
Mutual labels: pdf, puppeteer
Url To Pdf Api
Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.
Stars: ✭ 6,544 (+10454.84%)
Mutual labels: pdf, puppeteer
Diff Pdf
A simple tool for visually comparing two PDF files
Stars: ✭ 1,080 (+1641.94%)
Mutual labels: pdf
Python Documentcloud
A deprecated Python wrapper for the DocumentCloud API
Stars: ✭ 60 (-3.23%)
Mutual labels: pdf
Vivliostyle Cli
⚒ Supercharge command-line publication workflow.
Stars: ✭ 57 (-8.06%)
Mutual labels: pdf
O
🌀 Text editor suitable for writing git commit messages and editing Markdown files. Can build executables and jump to errors at the press of `ctrl-space`, for several programming languages. Can format code with `ctrl-w`. Provides general syntax highlighting, rainbow parenthesis and cut/paste portals. o is intentionally limited to VT100.
Stars: ✭ 54 (-12.9%)
Mutual labels: pdf
Ramayana book
Ramayana Book ( One of the two great epics of Hinduism ) ascribed by Valmiki
Stars: ✭ 52 (-16.13%)
Mutual labels: pdf
Caj2pdf
Convert CAJ (China Academic Journals) files to PDF. 转换中国知网 CAJ 格式文献为 PDF。佛系转换,成功与否,皆是玄学。
Stars: ✭ 1,063 (+1614.52%)
Mutual labels: pdf
html_to_pdf
Generate a simple PDF invoice from HTML using puppeteer & handlebars
Introduce
Puppeteer is Node.js library giving you access to a headless Chrome browser. This makes it a breeze to generate PDF files with Node.js
Handlebars provides the power necessary to let you build semantic templates effectively with no frustration
How to use
- Run
npm install
to install package in package.json - Run
node pdf.js
to generate invoice.pdf
The PDF Invoice from HTML
- Prepare content html (invoice.html)
- Using handlebars to binding data to content html
- Using Puppeteer to generate pdf from final html
const fs = require("fs");
const path = require("path");
const puppeteer = require('puppeteer');
const handlebars = require("handlebars");
(async () => {
var dataBinding = {
items: [{
name: "item 1",
price: 100
},
{
name: "item 2",
price: 200
},
{
name: "item 3",
price: 300
}
],
total: 600,
isWatermark: false
}
var templateHtml = fs.readFileSync(path.join(process.cwd(), 'invoice.html'), 'utf8');
var template = handlebars.compile(templateHtml);
var finalHtml = template(dataBinding);
var options = {
format: 'A4',
headerTemplate: "<p></p>",
footerTemplate: "<p></p>",
displayHeaderFooter: false,
margin: {
top: "40px",
bottom: "100px"
},
printBackground: true,
path: 'invoice.pdf'
}
const browser = await puppeteer.launch({
args: ['--no-sandbox'],
headless: true
});
const page = await browser.newPage();
await page.goto(`data:text/html,${finalHtml}`, {
waitUntil: 'networkidle0'
});
await page.pdf(options);
await browser.close();
})();
How to display paid stamp watermark on invoice?
Using handlebars to check param isWatermark
{{#if isWatermark}}
<div style="border-width: 6px;border-style: solid; border-color: #008000;border-radius: 8px; color: #008000; opacity:0.6; position: absolute; z-index: 1; left:40%; top:30%; font-size: 60pt;-webkit-transform: rotate(-45deg);-ms-transform: rotate(-45deg);transform: rotate(-45deg); font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;">
PAID </div>
{{/if}}
Change isWatermark: true
and run node pdf.js
again
License
html_to_pdf is available under the MIT license. See the LICENSE file for more info.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].