Hi Gal
I'm trying to use streams to write to when modifying an existing PDF (I don't want to overwrite the original and want to send the response back on the http stream without having to set a temp file to write to).
I have no problem getting this to work when I'm not modifying an existing file (the first step below) but I get an error for the second step when using an existing PDF:
TypeError: Unable to modify PDF file, make sure that output file target is available and that it is not protected
Any idea what I might be doing wrong in this case?
(This is based on ModifyExistingPageContent.js test so you'll have all the resources mentioned.)
Thanks,
Ross
var hummus = require('../hummus');
var fs = require('fs');
var outStream = fs.createWriteStream( './output/BasicJPGImagesTestPageModified.pdf' );
var pdfWriter = hummus.createWriter(new hummus.PDFStreamForResponse(outStream));
var page = pdfWriter.createPage(0, 0, 595, 842);
pdfWriter.startPageContentContext(page).writeText('Test Text',
75,
805,
{font:pdfWriter.getFontForFile('./TestMaterials/fonts/Couri.ttf'),size:14,colorspace:'gray',color:0x00});
pdfWriter.writePage(page).end();;
console.log('done simple write to stream');
var inStream = fs.createReadStream( './TestMaterials/BasicJPGImagesTest.PDF' );
var outStream2 = fs.createWriteStream( './output/BasicJPGImagesTestPageModified.pdf' );
pdfWriter = hummus.createWriterToModify(inStream, new hummus.PDFStreamForResponse(outStream2));
var pageModifier = new hummus.PDFPageModifier(pdfWriter,0);
pageModifier.startContext().getContext().writeText('Test Text',
75,
805,
{font:pdfWriter.getFontForFile('./TestMaterials/fonts/Couri.ttf'),size:14,colorspace:'gray',color:0x00});
pageModifier.endContext().writePage();
pdfWriter.end();
console.log('done - done write to stream for modification');