-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple pages from memory #54
Comments
Hello, Unfortunately it is not possible to add multiple input pages from stdin. This is more a wkhtmltopdf/os limitation than a bug here. But it seems you might be confusing input and output here. The HTML is rendered as normal and then printed as PDF document, so there is no theoretical limit to the number of pages in the output, if your HTML is long engouh it will be rendered to multiple pages. The issue is probably in your HTML code and not here, so I cannot say why your pages are blank, but
A third option, a probably the most simple option, is just appending the raw html files in a The following sample seems to render correctly (make sure the HTML documents begin with pdfg, err := NewPDFGenerator()
if err != nil {
log.Fatal(err)
}
htmlfile1, err := ioutil.ReadFile("D:\\header.html")
if err != nil {
log.Fatal(err)
}
htmlfile2, err := ioutil.ReadFile("D:\\body.html")
if err != nil {
log.Fatal(err)
}
htmlfile3, err := ioutil.ReadFile("D:\\footer.html")
if err != nil {
log.Fatal(err)
}
buf := new(bytes.Buffer)
buf.Write(htmlfile1)
buf.Write(htmlfile2)
buf.Write(htmlfile3)
pdfg.AddPage(NewPageReader(buf))
err = pdfg.Create()
if err != nil {
log.Fatal(err)
}
err = pdfg.WriteFile("./testfiles/merged.pdf")
if err != nil {
log.Fatal(err)
} This will render everything on one output page, to force page breaks you could do something like this: buf := new(bytes.Buffer)
buf.Write(htmlfile1)
buf.WriteString(`<P style="page-break-before: always">`)
buf.Write(htmlfile2)
buf.WriteString(`<P style="page-break-before: always">`)
buf.Write(htmlfile3)
pdfg.AddPage(NewPageReader(buf)) |
Cool! Thanks so much :) |
Hi, I want to create a multi-page document from
[][]byte
My current code is like this, where
pages
is of[][]byte
typeHowever, it seems that it's only producing one page of content, with the rest of pages being blank. I'm guessing it's something to do with this part inside
func (pdfg *PDFGenerator) run() error
, where the content of page is only being read once.Do you have any suggestion as how I should modify my code or there might be potential issue in the current code? Thanks a lot and I'm looking forward to your reply!
The text was updated successfully, but these errors were encountered: