Skip to content

Dockerized node webservice that take screenshot of webpage or convert them to PDF

License

Notifications You must be signed in to change notification settings

dynamicnet/screenshotr

Repository files navigation

Screenshot and PDF converter

Dockerized node webservice that take screenshot of webpage or convert it to PDF

# Launch Container
# The http service will listen on 127.0.0.1 on port 3000
docker run -p 3000:3000 -d dynamicnet/screenshotr

# Take a screenshot of GitHub homepage
curl http://127.0.0.1:3000/screenshot?url=https://github.com/ > github-home.png

# Convert GitHub homepage to PDF
curl http://127.0.0.1:3000/pdf?url=https://github.com/ > github.pdf

Parameters

endpoint /screenshot

Name Type Description
url required string url of the page to screenshot
username opt. string Username for HTTP auth basic authentication
password opt. string Password for HTTP auth basic authentication
vp_width opt. int set the viewport width in pixel. Defaults to 1024
vp_height opt. int set the viewport height in pixel. Defaults to 768
o_width opt. int set the width of the returned image. Default to the viewport width
o_height opt. int set the height of the returned image. Default to the viewport height
o_format opt. string (png|jpg) set image format for the returned image. Defaults to png
dom_element_selector opt. string a CSS selector of the element you want to screenshot, only if you don't want to screenshot the entire page
fullpage opt. int (0|1) "1" to take a screenshot of the fullpage, "0" to take a screenshot of the viewport only. Default to 0

endpoint /pdf

Name Type Description
url required string url of the page to screenshot
username opt. string Username for HTTP auth basic authentication
password opt. string Password for HTTP auth basic authentication
scale opt. float Scale of the webpage rendering. Defaults to 1. Scale amount must be between 0.1 and 2.
printBackground opt. bool Print background graphics. Defaults to false.
landscape opt. bool Paper orientation. Defaults to false.
format opt. string Paper format. Defaults to 'A4'.
delay opt. int Wait some time (in milliseconds) before converting. Defaults to 0.
pageRanges opt. string Paper ranges to print, e.g., '1-5, 8, 11-13'. Defaults to the empty string, which means print all pages.
headerTemplate opt. string HTML template for the print header.
footerTemplate opt. string HTML template for the print footer.
margin opt. map Keys: "top", "right", "bottom", "left". Values: string

Environments variables

Name Description
IGNORE_HTTPS_ERRORS If set, the launched browser will not complaint about invalid certifcate. Designed mainly for development environment that use self signed certifacate or Caddy Local Authority

About

Dockerized node webservice that take screenshot of webpage or convert them to PDF

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published