Closed thijsheijden closed 2 years ago
@thijsheijden I'm having the same issue, how did you solve it?
I can see in the source code that the writers n
value, but I don't see a way to manipulate that.
I updated to latest version, as mentioned here: https://github.com/phpdave11/gofpdi/issues/33 but still isn't working correctly with this code. @phpdave11 what am I doing incorrectly?
importer := gofpdi.NewImporter()
for _, attachment := range msg.Attachments {
rs := io.ReadSeeker(bytes.NewReader(attachment.Bytes))
tplID := importer.ImportPageFromStream(pdf, &rs, 1, "/MediaBox")
pdf.AddPage()
pdf.SetFillColor(238, 238, 238)
pdf.Rect(0, MarginTop, 210, ContentHeight-MarginTop, "F")
importer.UseImportedTemplate(pdf, tplID, 0, MarginTop, 0, ContentHeight-MarginTop)
}
I'll be diving into debugging it tomorrow.
Edit: I opened another issue and PR to fix this https://github.com/phpdave11/gofpdi/issues/59
Hi! Im trying to import multiple pages from a stream into a new PDF object. When using the following code:
I get the first page of the PDF perfectly fine. But when using a loop, or when adding a second page the same way as above (duplicating the code and changing the second import instance to page 2) the first page gets replaced by the second page, so the first two pages of the document are the second page of the document I am importing from. This same code works perfect when using
ImportPage
, so not sure why it is showing this strange behaviour when importing from a stream instead.This code duplicates the first page, all other pages are fine: