Merge pull request 'Upload files to "pdf"' (#4) from p3 into master
Reviewed-on: http://10.2.0.2:3000/jason/cpas/pulls/4
This commit was merged in pull request #4.
This commit is contained in:
@@ -1,8 +1,9 @@
|
|||||||
const puppeteer = require('puppeteer');
|
const puppeteer = require('puppeteer-core');
|
||||||
const buildHtml = require('./template');
|
const buildHtml = require('./template');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders the violation document HTML via Puppeteer and returns a PDF buffer.
|
* Renders the violation document HTML via Puppeteer and returns a PDF buffer.
|
||||||
|
* Uses the system Chromium installed in the Alpine image (no separate download).
|
||||||
* @param {object} violation - Row from violations JOIN employees
|
* @param {object} violation - Row from violations JOIN employees
|
||||||
* @param {object} score - Row from active_cpas_scores
|
* @param {object} score - Row from active_cpas_scores
|
||||||
* @returns {Buffer}
|
* @returns {Buffer}
|
||||||
@@ -26,8 +27,8 @@ async function generatePdf(violation, score) {
|
|||||||
await page.setContent(html, { waitUntil: 'networkidle0' });
|
await page.setContent(html, { waitUntil: 'networkidle0' });
|
||||||
|
|
||||||
const pdf = await page.pdf({
|
const pdf = await page.pdf({
|
||||||
format: 'Letter',
|
format: 'Letter',
|
||||||
printBackground: true,
|
printBackground: true,
|
||||||
margin: {
|
margin: {
|
||||||
top: '0.6in',
|
top: '0.6in',
|
||||||
bottom: '0.7in',
|
bottom: '0.7in',
|
||||||
|
|||||||
Reference in New Issue
Block a user