I'm trying to display a PDF on my browser using Webtask.io and keep getting the following error:
{
"code": 500,
"error": "Script generated an unhandled asynchronous exception.",
"details": "TypeError: dest.write is not a function",
"name": "TypeError",
"message": "dest.write is not a function",
"stack": "TypeError: dest.write is not a function\n at PDFDocument.ondata (_stream_readable.js:536:20)\n at emitOne (events.js:77:13)\n at PDFDocument.emit (events.js:169:7)\n at PDFDocument.Readable.read (_stream_readable.js:368:10)\n at flow (_stream_readable.js:751:26)\n at resume_ (_stream_readable.js:731:3)\n at nextTickCallbackWith2Args (node.js:442:9)\n at process._tickDomainCallback (node.js:397:17)"
}
Does anyone know why this would be happening? Here is my code.
var fs = require('fs');
var PDFDocument = require('pdfkit@0.7.2');
var blobStream = require('blob-stream');
var ace = require('braces@1.8.0');
module.exports =
function (req,res,next) {
doc = new PDFDocument();
doc.pipe(res);
doc.moveTo(300, 75)
.lineTo(373, 301)
.lineTo(181, 161)
.lineTo(419, 161)
.lineTo(227, 301)
.fill('red', 'even-odd');
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.end();
}
via bryan
No comments:
Post a Comment