https://github.com/jeffersonlab/puppet-show
Programmatically execute Chromium print-to-pdf and screenshot
https://github.com/jeffersonlab/puppet-show
acg nodejs-workflows pdf pdf-generation puppeteer screenshot service
Last synced: 11 months ago
JSON representation
Programmatically execute Chromium print-to-pdf and screenshot
- Host: GitHub
- URL: https://github.com/jeffersonlab/puppet-show
- Owner: JeffersonLab
- License: mit
- Created: 2018-05-15T15:57:50.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2025-03-30T13:11:18.000Z (12 months ago)
- Last Synced: 2025-05-02T15:42:51.014Z (11 months ago)
- Topics: acg, nodejs-workflows, pdf, pdf-generation, puppeteer, screenshot, service
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/puppet-show
- Size: 615 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Puppet Show [](https://hub.docker.com/r/jeffersonlab/puppet-show) [](https://www.npmjs.com/package/puppet-show)
Leverages the [Puppeteer](https://github.com/GoogleChrome/puppeteer) library to expose Chromium print-to-pdf and screenshot over a service

---
- [Overview](https://github.com/jeffersonlab/puppet-show#overview)
- [Quick Start with Compose](https://github.com/jeffersonlab/puppet-show#quick-start-with-compose)
- [Install](https://github.com/jeffersonlab/puppet-show#install)
- [API](https://github.com/jeffersonlab/puppet-show#api)
- [Configure](https://github.com/jeffersonlab/puppet-show#configure)
- [Release](https://github.com/jeffersonlab/puppet-show#release)
- [Deploy](https://github.com/jeffersonlab/puppet-show#deploy)
- [See Also](https://github.com/jeffersonlab/puppet-showi#see-also)
---
## Overview
Use this web service to programatically convert web pages to PDF or image. For example, create a cron job that uses the service to generate a daily report PDF from a web page and then email it. The HTML form allows you to easily build your request for embedding in an application. This service should only be installed internally on an intranet and not exposed to the Internet as it can be easily abused and would be a high security risk (For example using a file:// protocol in the URL exposes local files).
## Quick Start with Compose
1. Grab project
```
git clone https://github.com/jeffersonlab/puppet-show
cd puppet-show
```
2. Launch [Compose](https://github.com/docker/compose)
```
docker compose up
```
3. Launch web browser
```
http://localhost:3000/puppet-show
```
**Note**: Container requires `privileged` mode in order to launch Chrome in a sandbox.
## Install
```bash
npm i puppet-show
npm start
```
**Note**: This application runs on the Node.js JavaScript runtime, which can be downloaded [here](https://nodejs.org/en/download/).
## API
The URL parameter names for the web service end point __puppet-show/pdf__ and __puppet-show/screenshot__ mirror the option names for the puppeteer print-to-pdf and screenshot functions found [here](https://pptr.dev/api). The puppet-show web forms can also be used to explore the API.
**Note**: The default values match the puppeteer defaults and the only required parameter is "url".
## Configure
```bash
export PORT=3000
npm start
```
**Note**: Use the appropriate set environment variable command for your shell; Bash shell shown above. For C Shell use "setenv PORT 3000", and for Windows use "set PORT 3000".
## Release
0. Bump the version number in package.json and the two instances in package-lock.json.
1. Bump the version number in the VERSION file and commit and push to GitHub (using [Semantic Versioning](https://semver.org/)).
2. The [CD](https://github.com/JeffersonLab/puppet-show/blob/main/.github/workflows/cd.yaml) GitHub Action should run automatically invoking:
- The [Create release](https://github.com/JeffersonLab/nodejs-workflows/blob/main/.github/workflows/gh-release.yaml) GitHub Action to tag the source and create release notes summarizing any pull requests. Edit the release notes to add any missing details.
- The [Publish NPM](https://github.com/JeffersonLab/nodejs-workflows/blob/main/.github/workflows/npm-publish.yaml) GitHub Action to create a deployment artifact on NPM.
- The [Publish docker image](https://github.com/JeffersonLab/container-workflows/blob/main/.github/workflows/docker-publish.yaml) GitHub Action to create a new demo Docker image.
## Deploy
The app is deployed at JLab on nodejs9.acc.jlab.org.
## See Also
- [Puppet Show Wiki](https://github.com/jeffersonlab/puppet-show/wiki)
- [Chrome Remote Control (DevTools) Protocol](https://chromedevtools.github.io/devtools-protocol/tot/Page#method-printToPDF)
- [Puppetron](https://github.com/cheeaun/puppetron)
- [URL-to-PDF-API](https://github.com/alvarcarto/url-to-pdf-api)
