Private Sub PrintTable(NumRows As Int, NumCols As Int, Tbl(,) As String, X As Int, Y As Int, W As Int, H As Int)
Dim pdf As cPDF
pdf.Initialize("mm")
pdf.pageAdd(pdf.pageSizeA4PortraitWidth, pdf.pageSizeA4PortraitHeight)
pdf.sFont( _
pdf.fontHelvetica, _
pdf.fontBold, _
12, _
pdf.colorBlack _
)
Dim RowY(NumRows + 1) As Float
For R = 0 To NumRows
RowY(R) = Y + R / NumRows * H
Log(R & TAB & RowY(R))
Next
Dim ColX(NumCols + 1) As Float
For C = 0 To NumCols
ColX(C) = X + C / NumCols * W
Log(C & TAB & ColX(C))
Next
ColX(1) = ColX(1) - 10 'demo individual column widths
'draw table grid
For R = 0 To NumRows
pdf.outLine(ColX(0), FlipY(RowY(R)), ColX(NumCols), FlipY(RowY(R)))
Next
For C = 0 To NumCols
pdf.outLine(ColX(C), FlipY(RowY(0)), ColX(C), FlipY(RowY(NumRows)))
Next
'draw table contents
For R = 0 To NumRows - 1
For C = 0 To NumCols - 1
pdf.outtext(ColX(C) + 2.0, FlipY(RowY(R) + 5.0), Tbl(R, C))
Next
Next
'save to file with compression if data compressed are smaller
savePDF(pdf,"test.pdf",pdf.CompressAlways)
'open with default viewer
openPDF("test.pdf")
End Sub