Pdf rendering service with electron
With Docker:
$ docker run -p 3000:3000 bro0k/electron-pdf
Run locally
$ npm i -g electron-prebuilt
$ electron .
url
: Absolute url to the webpage you want to have rendered.
$ curl http://localhost:3000/https://www.google.com > google.pdf
Send a html string as the request body.
$ curl -L https://www.google.com | curl -X POST -d @- http://localhost:3000/ > google.pdf
Use following request headers to control the output pdf appearance.
x-pdf-orientation
:landscape
orportrait
- Page orientation, defaults toportrait
.x-pdf-no-backgrounds
: Presence of this header prevents backgrounds from being printed.x-pdf-margins
:default
,none
orminimum
- Margin type, defaults todefault
.x-pdf-pageSize
:A4
,A3
,Legal
,Letter
orTabloid
- Paper size, defaults toA4
.x-pdf-pageSize
:A4
,A3
,Legal
,Letter
orTabloid
- Paper size, defaults toA4
.x-pdf-outputWait or x-pdf-printDelay
: Time to wait (in MS) between page load and PDF creation. If used in conjunction with -e this will override the default timeout of 10 seconds.x-pdf-waitForJSEvent
: The name of the event to wait before PDF creation .