I have a pdf wrapper for gofpdf which is writing tables, the code to write rows looks like this, the headers of the table is another story...
func WriteTableRows(pdf *gofpdf.Fpdf, fontSize float64, columnSize []float64, rows [][]string) *gofpdf.Fpdf {
pdf.SetFont("Times", "", fontSize)
_, pageh := pdf.GetPageSize()
marginCell := 2.
_, _, _, mbottom := pdf.GetMargins()
_, lineHt := pdf.GetFontSize()
for _, row := range rows {
curx, y := pdf.GetXY()
x := curx
height := splitLines(row, pdf, columnSize, lineHt, marginCell)
y = AddAnotherPage(pdf, height, pageh, mbottom, y)
for i, txt := range row {
width := columnSize[i]
pdf.Rect(x, y, width, height, "")
pdf.MultiCell(width, lineHt+marginCell, txt, "", "", false)
x += width
pdf.SetXY(x, y)
}
pdf.SetXY(curx, y+height)
}
return pdf
}
This source code prepares a bunch of rows to be written in the pdf file, But the thing is that all information remains in memory and I have very big tables to write, how can I write what is already processed and free the memory without close the file, because after a bunch of rows prepared, I need to read another set and 'prepare' it again, or maybe even closing the file but open again to append the next set of rows.