Open jchapelle opened 5 years ago
try adding a 3rd parameter to the PDFPageModifier
creation call, like this:
new hummus.PDFPageModifier(pdfWriter, 0, true);
while there's no z-index definition in pdf (it's just that's what's drawn later in the code, is on top...and in PDFPageModifier
the new code will appear later), it is possible that there are global matrix effects on the page, which may make your code function differently. to fully isolate your code in terms of transformation, pass true
as an additional param.
Thanks for the feedback. Unfortunately it still does not work. I can send you the files if you want.
On Fri, Apr 26, 2019 at 9:31 AM gal kahana notifications@github.com wrote:
try adding a 3rd parameter to the PDFPageModifier creation call, like this: new hummus.PDFPageModifier(pdfWriter, 0, true);
while there's no z-index definition in pdf (it's just that's what's drawn later in the code, is on top...and in PDFPageModifier the new code will appear later), it is possible that there are global matrix effects on the page, which may make your code function differently. to fully isolate your code in terms of transformation, pass true as an additional param.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/galkahana/HummusJS/issues/377#issuecomment-486957521, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPAMXKSYGNFAIHIVPFTDH3PSKVU5ANCNFSM4HIQKXOQ .
-- Jean Chapelle
Hello. I have the same problem. Please help me. This is my code:
const addPNG = async (pdfDocument, pngBuffer, callback) => {
const outStream = new WritableStream();
const outStreamResponse = new hummus.PDFStreamForResponse(outStream);
const pdfStream = new hummus.PDFRStreamForBuffer(pdfDocument);
const pdfWriter = hummus.createWriterToModify(pdfStream, outStreamResponse);
const pngStream = new hummus.PDFRStreamForBuffer(buffer);
const pageModifier = new hummus.PDFPageModifier(pdfWriter, 0, true);
const imageXObject = pdfWriter.createFormXObjectFromPNG(path.join(pngStream);
const ctx = pageModifier.startContext().getContext();
ctx.q()
.cm(256, 0, 0, 256, 0, 0)
.doXObject(imageXObject)
.Q();
pageModifier.endContext().writePage();
pdfWriter.end();
return callback(outStream.toBuffer());
};
I don`t catch any errors. The size of the pdf file becomes larger, but when I open it, I see no changes. Please help me figure out what the problem is.
I didn't get answers to my questions and I finally ended up doing my pdf manipulation with a java program ...
On Mon, Jul 1, 2019 at 5:16 PM Stanislav Pipa notifications@github.com wrote:
Hello. I have the same problem. Please help me. This is my code:
const addPNG = async (pdfDocument, pngBuffer, callback) => { const outStream = new WritableStream(); const outStreamResponse = new hummus.PDFStreamForResponse(outStream); const pdfStream = new hummus.PDFRStreamForBuffer(pdfDocument); const pdfWriter = hummus.createWriterToModify(pdfStream, outStreamResponse);
const pngStream = new hummus.PDFRStreamForBuffer(buffer);
const pageModifier = new hummus.PDFPageModifier(pdfWriter, 0, true);
const imageXObject = pdfWriter.createFormXObjectFromPNG(path.join(pngStream);
const ctx = pageModifier.startContext().getContext();
ctx.q() .cm(256, 0, 0, 256, 0, 0) .doXObject(imageXObject) .Q();
pageModifier.endContext().writePage(); pdfWriter.end();
return callback(outStream.toBuffer()); };
I don`t catch any errors. The size of the pdf file becomes larger, but when I open it, I see no changes. Please help me figure out what the problem is.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/galkahana/HummusJS/issues/377?email_source=notifications&email_token=ABPAMXOGUQMCHCAZN66BP33P5INTTA5CNFSM4HIQKXO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY6ON4Q#issuecomment-507307762, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPAMXMS727PDKTPCOEJOMLP5INTTANCNFSM4HIQKXOQ .
-- Jean Chapelle
I managed to print an image in an existing pdf which is actually a blank page. But when I try to print an image in an other existing pdf (with the exact same code) which is not a blank page, the image does not appear. Is there some z-index in image placement ? Is it possible to specify that an image should be in front of everything else ?