Below is my code for pdf importer. I am trying to merge 2 pdf as 1. In this case, rsbp is one pdf and rsinv is another one. the system should be that first page of the pdf will have the content of rsbp and then rest of the pdf is rsinv. When i run this code i see the second page rsinv is ok but first page (where it should have the content of rsbp),has the content of the first page of rsinv.
now if i change it to inport page and manually input 2 files then everything works great(problem happens when converted to stream).
IF i remove the loop part then the outputpdf has the content of rsbp which is correct.
Not what is the issue here.
pdf := gofpdf.New("P", "mm", "A4", "")
w, h := m.GetPageSize()
imp1 := gofpdi.NewImporter()
rsbp := io.ReadSeeker(bytes.NewReader(pdfm.Bytes()))
tpl1 := imp1.ImportPageFromStream(pdf, &rsbp, 1, "/MediaBox")
pdf.AddPage()
imp1.UseImportedTemplate(pdf, tpl1, 0, 0, w, h)
rsinv := io.ReadSeeker(bytes.NewReader(bikepass.Invoicebyte))
tpl1 = imp1.ImportPageFromStream(pdf, &rsinv, 1, "/MediaBox")
nrPages := len(imp1.GetPageSizes())
for i := 1; i <= nrPages; i++ {
pdf.AddPage()
if i > 1 {
tpl1 = imp1.ImportPageFromStream(pdf, &rsinv, i, "/MediaBox")
}
imp1.UseImportedTemplate(pdf, tpl1, 0, 0, w, h)
}
err := pdf.OutputFileAndClose("pdfs/example.pdf")
if err != nil {
fmt.Errorf("error in generating the output pdf file: %w", err)
}
I just checked the system. If i pass the second pdf as a file with importpage function then all is good. My guess is that it can not work with 2 pdf stream.
Below is my code for pdf importer. I am trying to merge 2 pdf as 1. In this case, rsbp is one pdf and rsinv is another one. the system should be that first page of the pdf will have the content of rsbp and then rest of the pdf is rsinv. When i run this code i see the second page rsinv is ok but first page (where it should have the content of rsbp),has the content of the first page of rsinv.
now if i change it to inport page and manually input 2 files then everything works great(problem happens when converted to stream).
IF i remove the loop part then the outputpdf has the content of rsbp which is correct.
Not what is the issue here.
pdf := gofpdf.New("P", "mm", "A4", "")