All Projects → isneezy → pdf-generator-service

isneezy / pdf-generator-service

Licence: MIT License
A simple express service that generates a pdf based on the submitted HTML

Programming Languages

typescript
32286 projects
Dockerfile
14818 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to pdf-generator-service

puppeteer-report
Convert HTML to PDF by Puppeteer with support of adding a custom header, footer, and page number
Stars: ✭ 90 (+221.43%)
Mutual labels:  html-to-pdf
markdown-index
Generate a global index for multiple markdown files recursively
Stars: ✭ 15 (-46.43%)
Mutual labels:  toc-generator
html-to-pdf-convertor
HTML to PDF convertor for Android
Stars: ✭ 45 (+60.71%)
Mutual labels:  html-to-pdf
docraptor-ruby
A native Ruby client for the DocRaptor HTML to PDF generation API
Stars: ✭ 20 (-28.57%)
Mutual labels:  html-to-pdf
pydf
PDF generation in python using wkhtmltopdf for heroku and docker
Stars: ✭ 68 (+142.86%)
Mutual labels:  html-to-pdf
fpdf-easytable
fpdf-easyTable is a PHP class that makes it easy to build tables for PDF documents generated with the FPDF library
Stars: ✭ 74 (+164.29%)
Mutual labels:  html-to-pdf
shuttlepdf
📃 Smashingly simple, and scalable ("serverless") HTML to PDF conversions using Google Cloud Functions, and Puppeteer.
Stars: ✭ 15 (-46.43%)
Mutual labels:  html-to-pdf
gitbook-plugin-atoc
A TOC plugin for GitBook
Stars: ✭ 22 (-21.43%)
Mutual labels:  toc-generator
Docotic.Pdf.Samples
C# and VB.NET samples for Docotic.Pdf library
Stars: ✭ 52 (+85.71%)
Mutual labels:  html-to-pdf
gitbook-plugin-page-toc
Add Table of Contents (TOC) to every page in your GitBook.
Stars: ✭ 25 (-10.71%)
Mutual labels:  toc-generator
api2pdf.php
PHP client library for the Api2Pdf.com REST API - Convert HTML to PDF, URL to PDF, Office Docs to PDF, Merge PDFs, HTML to Image, URL to Image, HTML to Docx, HTML to Xlsx, PDF to HTML, Thumbnail preview of office files
Stars: ✭ 42 (+50%)
Mutual labels:  html-to-pdf
HTMLWithImagesToPDF
Generate a PDF from an HTML file containing images (iOS).
Stars: ✭ 38 (+35.71%)
Mutual labels:  html-to-pdf
Athenapdf
Drop-in replacement for wkhtmltopdf built on Go, Electron and Docker
Stars: ✭ 2,160 (+7614.29%)
Mutual labels:  html-to-pdf
Dompdf
HTML to PDF converter for PHP
Stars: ✭ 8,446 (+30064.29%)
Mutual labels:  html-to-pdf
Snappy
PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage
Stars: ✭ 3,986 (+14135.71%)
Mutual labels:  html-to-pdf
Pdfkit
A Ruby gem to transform HTML + CSS into PDFs using the command-line utility wkhtmltopdf
Stars: ✭ 2,799 (+9896.43%)
Mutual labels:  html-to-pdf
python-pdfkit-example
python-pdfkit HTML TO PDF Example
Stars: ✭ 18 (-35.71%)
Mutual labels:  html-to-pdf

Express PDF Generator Service

Build Docker Build Coverage Status

A simple express service that generates a pdf based on the submitted HTML using Chromium and Puppeteer.

Getting started

Running locally

## build
yarn install
yarn build
## Running the server
node ./dist/src/index.js
## Or simply
yarn start

Running with docker

docker run --rm -p 3000:3000 --name=service isneezy/pdf-generator

Check our docker hub repository for available tags

API

The webserver started by express.js has one JSON endpoint to generate PDFs.

POST /generate

Will generate a PDF based on the given payload data and returns the pdf file as a stream

{
 "content": "", // required - HTML string/handlebars template to be converted to PDF,
 "context": {}, // object with the data to be passed to handlebars template engine
 "orientation": "portrait", // optional - possible values ["portrait", "landscape"]
 "format": "A4", // optional - possible values  ["Letter", "Legal", "Tabloid", "Ledger", "A0", "A1", "A2", "A3", "A4", "A5", "A6"]
 "header": "", // optional - HTML template for the print header. See https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagepdfoptions
 "footer": "" // optional - HTML template for the print footer. available context variables date: title, url, pageNumber, totalPages and pageNumber. Note these variables should be used with 3 mustaches ex: {{{ pageNumber }}}
}
Example
{
 "content": "<h2>Hello from Express PDF Generator Service</h2><p>Writen by {{ author }}</p>",
 "context": { "author": "Ivan Vilanculo <[email protected]>" },
 "orientation": "portrait",
 "format": "A5",
 "footer": "<p>{{ name }} &copy; {{{ date }}}, page {{{ pageNumber }}} of {{{ totalPages }}}</p>"
}

Generating table of contents (TOCs)

PDF Generator Service can generate TOCs for your document. All you have to do is simply add the template for your TOCs inside an element with .print-toc class.

Note:

  1. This feature highly relies on semantic HTML, which means that all heading tags (h1, h2, h3, h4, h5, and h6) will be used to create your TOCs. Add toc-ignore class to a heading tag if you want to ignore.
  2. TOCs will always appear or be rendered on the first pages of your document.
<html>
<body>
<div class="print-toc">
<h1>Table of contents</h1>
{{#each _toc}}
<a style="display: flex; margin-bottom: 6px; text-decoration: none; color: inherit" href="{{ this.href }}">
    <div>{{ this.title }}</div>
    <div style="margin: 0 4px; flex: 1; border-bottom: 2px dotted black"></div>
    <div>{{ this.page }}</div>
</a>
{{/each}}
</div>
<!-- place your document markup content here and all heading tags will be used to create TOCs -->
</body>
</html>
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].