go-pdf / fpdf

A PDF document generator with high level support for text, drawing and images
MIT License
515 stars 46 forks source link

Create a PDF based on template to display a large data file #42

Open azamss opened 1 year ago

azamss commented 1 year ago

https://gist.github.com/azamss/4c0dbea4c7c79af97f54e827f7a8ff5d

I have a file whose number of lines is more than one page. Using the sample code that I linked, I was able to create only one PDF page but i want to display all data. How can I solve this problem?

sbinet commented 1 year ago

is this example useful ? https://pkg.go.dev/github.com/go-pdf/fpdf#Fpdf.SetAcceptPageBreakFunc

azamss commented 1 year ago

No, I use the table to display the data inside the file. The link below is an example of a file https://gist.github.com/azamss/5988663277c52ffc8497fc94ef61e0d1

neox5 commented 5 months ago

I think you have 2 possiblities: 1) pre-calculate the height of all the text when rendered and insert the pdf.AddPage() accordingly. 2) or calculate the rest of the page and necessary height of the text block. If height exseeds the rest of the page add new page