Hello all,
I can generate pdf tables easily enough from a database RowSet/s, but am a little forgetful of how to create and populate a pdf table more manually using PDFTableDataSource.PaintHeaderContent and PDFTableDataSource.PaintCell.
So I’ve made it to the end of a 22 page pdf and needed to add a table things calc’d along the journey (in other words) without using a RowSet.
I am guessing you do something like…not sure of the approach, but
Var d As New PDFDocument(PDFDocument.PageSizes.A4)
Var g As Graphics = d.Graphics
Var t As New PDFTable
t.ColumnCount = 3
t.ColumnWidths = "150,150,150"
Var tds As PDFTableDataSource
tds.PaintHeaderContent(g.DrawText("ColOneHeader", 10, 25, 150), 0)
tds.PaintHeaderContent(g.DrawText("ColTwoHeader", 10, 25, 150), 1)
tds.PaintHeaderContent(g.DrawText("ColThreeHeader", 10, 25, 150), 2)
tds.PaintCell(g.DrawText("RowOneColOne", 10, 50, 150), 0, 0)
tds.PaintCell(g.DrawText("RowOneColTwo", 160, 50, 150), 0, 1)
tds.PaintCell(g.DrawText("RowOneColThree", 310, 50, 150), 0, 2)
tds.PaintCell(g.DrawText("RowTwoColOne", 10, 75, 150), 0, 0)
tds.PaintCell(g.DrawText("RowTwoColTwo", 160, 75, 150), 0, 1)
tds.PaintCell(g.DrawText("RowTwoColThree", 310, 75, 150), 0, 2)
t.DataSource = tds
d.AddTable(t, 40, 40)
…and sure I’d normally calc X and Y, and I then load for viewing… however this code bombs on PaintHeaderContent and PaintCell, even when I break out the g (graphics).
I was wondering if anyone has an example of the correct approach for building a pdf table from scratch?
Kind regards, Andrew