Skip to content

ElasticSuite/chrome-print

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chrome-print

A headless chrome process with an express-based API in front of it. Upload an HTML file, specify width and height, get a PDF back.

Run

docker-compose up

Usage

# get the port the server is listening on
port=`docker ps |grep chromeprint_print |sed 's/.*:\([0-9]*\)-.*/\1/'`

# send the request
curl \
  -F "htmlFile=@test.html" \
  -F "width=8.5" \
  -F "height=11" \
  -X POST \
  -H "Content-Type: multipart/form-data" \
  -o test.pdf \
  http://localhost:$port/

Attribution

I basically copied and adapted code from this guy. My whole solution is obviously cobbled together from various slapped together sources, but it fits my needs.