Simple PDF rendering server using Headless Chrome & Express & Puppeteer
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app fix typo update README Aug 29, 2018
fonts add fonts.conf Aug 22, 2018
test Improve pdf options Aug 27, 2018
.gcloudignore edit README and add support for GAE Aug 22, 2018
.gitignore add fonts.conf Aug 22, 2018
Dockerfile add test Aug 27, 2018
LICENSE Initial commit Feb 13, 2018 update README Aug 29, 2018
app.yaml change instance Aug 24, 2018
package.json fix typo update README Aug 29, 2018


Simple and fast PDF rendering server. Using Headless Chrome & Express & Puppeteer.

GET URL or POST HTML returns PDF binary.

You can run this on Docker container, Kubernetes(GKE), or Google App Engine(beta).

Headless Chrome



Running on Google App Engine Supported (beta)

Instead of Docker container, You can also run this on Google App Engine. Please use app.yaml and edit it for your purpose.

gcloud app deploy --project your-project

More detail:

Getting Started


Since this product is supposed to be used within local network (like Kubernetes, GKE), error control and security measures are minimum, please accept only reliable requests. It does not assume direct disclosure to the outside.


git clone this repository.

Install fonts (optionary)

If you convert pages in Japanese, Chinese or languages other than English, you will need to install each font files. Also, you can use WEB fonts, but since it takes a long time for requesting and downloading them, we recommend that install the font files in the server.

cp AnyFonts.ttf ./fonts/

Build image

sudo docker build -t hcep-pdf-server:latest .


Below example, run with 8000 port.

sudo docker run -it --rm \
    -p 8000:8000 \
    --name hcep-pdf-server \


Get request with url parameter

curl "http://localhost:8000?url=" -o hcep-pdf-get.pdf

POST request with html parameter

curl -sS http://localhost:8000 -v -d html=hcep-pdf-ok -o hcep-pdf-post.pdf

Please note that because the page does not have a URL, when sending html in POST method, you can not use a relative path.

So, you need to include external files with domain.

Bad, not working

<link href="/static/style.css" rel="stylesheet">


<link href="" rel="stylesheet">


Execute mocha in the container run with the above command.

% sudo docker exec varuna-hcep-pdf-server mocha
SERVER_URL: http://localhost:8000
HTML_TEST_STRINGS: <html>ok</html>

  requests routes
    ✓ Health Check GET /hc
    ✓ GET / with no url
    ✓ GET / with url (262ms)
    ✓ POST / html=<html>ok</html>
    ✓ GET /screenshot with url (245ms)
    ✓ POST /screenshot html=<html>ok</html> (82ms)

  6 passing (621ms)

Env variables

Browser settings


Whether to use chromium attached to puppeteer. If you want to run this on Google App Engine, you must set it to "true".

default: false (use installed Chrome by Dockerfile)


The path of installed google-chrome binary. If HCEP_USE_CHROMIUM is true, this value is ignored

default: /usr/bin/google-chrome


Timeout milliseconds of the browser's Page default: 10000

Server settings


Listen Port by the express app

default: 8000


Timeout milliseconds of the express app

default: 30000


default: 10mb

PDF settings


default: 18mm


default: A4

Test settings


default: 'http://localhost:8000'


default: ''

Customize PDF options

You can customize PDF with options. Read the puppeteer API's docs.



This project has been maintained under the support of yagish履歴書 and is actually used for PDF generation.

yagish履歴書( bizocean co.,Ltd )