Closed CaptnBlubber closed 6 years ago
I am trying to add Content to an existing file and output the result as Response.
I keep getting TypeError: Unable to modify PDF file, make sure that output file target is available and that it is not protected as an Error.
TypeError: Unable to modify PDF file, make sure that output file target is available and that it is not protected
Here is the code that I am working with:
response.setHeader("Content-Type", "application/pdf"); var pdfWriter = hummus.createWriterToModify(new hummus.PDFRStreamForFile(path.join(__dirname, 'assets/input.pdf')), new hummus.PDFStreamForResponse(response)); var pageModifier = new hummus.PDFPageModifier(pdfWriter, 0); var cxt = pageModifier.startContext().getContext(); var pathFillOptions = {color:0xFF000000, colorspace:'cmyk', type:'fill'}; var pathStrokeOptions = {color:0xFF00FF, width:4}; // drawPath cxt.drawPath(75,640,149,800,225,640,pathFillOptions) .drawPath(75,540,110,440,149,540,188,440,223,540,pathStrokeOptions); // drawSquare cxt.drawSquare(375,640,120,pathFillOptions) .drawSquare(375,440,120,pathStrokeOptions); // drawRectangle cxt.drawRectangle(375,220,50,160,pathFillOptions) .drawRectangle(375,10,50,160,pathStrokeOptions); // drawCircle cxt.drawCircle(149,300,80,pathFillOptions) .drawCircle(149,90,80,pathStrokeOptions); pageModifier.endContext().writePage(); pdfWriter.end(); response.send();
As for environment, I am using Firebase cloud functions. The code for writing the response works if creating a new PDF from scratch.
Nevermind I got it fixed. Seems like firebase wasn't updating my function properly. I changed my functions name redeployed and it worked.
I am trying to add Content to an existing file and output the result as Response.
I keep getting
TypeError: Unable to modify PDF file, make sure that output file target is available and that it is not protected
as an Error.Here is the code that I am working with:
As for environment, I am using Firebase cloud functions. The code for writing the response works if creating a new PDF from scratch.