Open simonaberry opened 5 years ago
Got it working. Trick was to not use two different PDF writers :
// [A] open the coverpage from a file for modifiction
var inStream = new hummus.PDFRStreamForFile(...);
pdfWriter = hummus.createWriterToModify(inStream, byteArray);
// [B] add text to coverpage
var pageModifier = new hummus.PDFPageModifier(pdfWriter,0);
pageModifier.startContext().getContext().writeText(...);
pageModifier.endContext().writePage();
// [C] create pages dynamically
pdfWriter.createPage(...);
pdfWriter.startPageContentContext(...);
pdfWrite.writePage(...);
// [D] add backpage from file
pdfWriter.appendPDFPagesFromPDF(...);
pdfWriter.end();
I have working application where we
createWriter
write to a custom ByteArray streampdfWriter.appendPDFPagesFromPDF
createPage
,startPageContentContext
, etc)pdfWriter.appendPDFPagesFromPDF
As mentioned this is all working perfectly.
Now, however, I wish to Modify the coverpage (add text to it)... but am struggling to get both
createWriter
andcreateWriterToModify
to work on the same output stream. This is my approach :While the code is executing without any errors, the resultant output file does not include the coverpage [A] & [B] at all. It only consists of the dynamic content [C] and the backpage [D].
Is it possible to have
createWriter
andcreateWriterToModify
to work on the same output stream ?