I am new to javascript and I'm trying to make a PDF file from a firebase function using pdfkit. Below is my function code.
const pdfkit = require('pdfkit');
const fs = require('fs');
exports.PDFTest = functions.https.onRequest((req, res) => {
var doc = new pdfkit();
var loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in...';
doc.y = 320;
doc.fillColor('black')
doc.text(loremIpsum, {
paragraphGap: 10,
indent: 20,
align: 'justify',
columns: 2
});
doc.pipe( res.status(200) )
});
The function starts but then a timeout error happens. Is this the best way of going about creating a pdf file in firebase? I have some html that I want made into a pdf file.
However, after the template has been apparently correctly compiled, I get the following error... Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.
– Renaud Tarnec Feb 01 '18 at 09:58