- Install Node.JS
- Open the command prompt in the directory GenPDFService.js exist.
- Install Puppeteer by type
npm install puppeteer
- To run the service type
node GenPDFService.js
To set up this service on a windows machine to autostart when windows loads.
- Copy all the contents of this folder to c:\PDFService\
- Open command prompt to c:\PDFService
- Type the following commands
npm install node-windows
node WindowsInstallService.JS
- Open your terminal window to install nodeJS
- Type the following commands
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install nodejs
sudo apt-get install build-essential
sudo apt-get install GConf2
npm install puppeteer
- To run type the following command into the terminal
node GenPDFService.js
- type the following commands
sudo npm install -g pm2
pm2 start GenPDFService.js
pm2 startup systemd
- pm2 will generate a script for you copy and paste it into the terminal
- Type the following
pm2 save
- If for some reason this service does not start on reboot type
pm2 resurrect
- Open a command prompt to c:\PDFService
- Type the following command
node WindowsUnintallService.JS
- Open the terminal and type
pm2 delete GenPDFService
You can set the default configuration of the service by changing the constants at the top of the GenPDFService.js file.
| Varible | Description |
|---|---|
| port | Port number to listen to |
| psuedoHost | Host to display in footer |
| defaultShowHeaderFooter | determines if header and footer should be displayed |
| Default Format | determines what the default format should be. accepted formats are Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A6 |
When you make a call to the service you need to make a HTTP POST on port the port defined default 8080. The body of the Post needs to contain the HTML that you wish to convert to a PDF, and PDF Specific configurations will be entered into the Querystring.
For example: http://<PDFService.URL>:8080?showHeaderFooter=true&host=http://google.com&format=A4
The querystring parameters will override the config variables
| Varible | Description |
|---|---|
| host | Host to display in footer |
| showHeaderFooter | determines if header and footer should be displayed |
| format | determines what the default format should be. accepted formats are Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A6 |