Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control SaveButton Inherits PushButton
ControlInstance SaveButton Inherits PushButton
EventHandler Sub Action()
// setup PDF
dim pdf as new MyDynaPDFMBS
call pdf.CreateNewPDF
call pdf.SetPageCoords(pdf.kpcTopDown)
// create table
dim ColumnCount as integer = List.ColumnCount
dim tbl as DynaPDFTableMBS = pdf.CreateTable(3, ColumnCount, 500.0, 100.0)
call tbl.SetBorderWidth(-1, -1, 1.0, 1.0, 1.0, 1.0)
call tbl.SetGridWidth( 1.0, 1.0)
call tbl.SetGridHorizontalColor(100, 100, 100)
call tbl.SetGridVerticalColor(100, 100, 100)
call tbl.SetBorderColor(-1, -1, 100, 100, 100)
// add header row
dim rowNum as integer = tbl.AddRow
call tbl.SetFlags rowNum, -1, tbl.ktfHeaderRow
for i as integer = 0 to ColumnCount-1
call tbl.SetCellText rowNum, i, pdf.ktaLeft, tbl.kcoCenter, List.Heading(i)
next
// now fill all the cells
dim c as integer = List.ListCount-1
for Row as integer = 0 to c
rowNum = tbl.AddRow
for Column as integer = 0 to ColumnCount-1
// which alignment for this cell?
dim AlignMent as integer = pdf.ktaLeft
Select case List.ColumnAlignment(column)
case List.AlignCenter
AlignMent = pdf.ktaCenter
case List.AlignRight
AlignMent = pdf.ktaRight
end Select
call tbl.SetCellText rowNum, Column, AlignMent, tbl.kcoCenter, list.Cell(row, Column)
next
next
// Draw the table now
call pdf.Append
call tbl.DrawTable(50.0, 50.0, 742.0)
while tbl.HaveMore
call pdf.EndPage
call pdf.Append
call tbl.DrawTable(50.0, 50.0, 742.0)
wend
call pdf.EndPage
// A table stores errors and warnings in the error log
dim err as DynaPDFErrorMBS
dim ErrLogMessageCount as integer = pdf.GetErrLogMessageCount
for i as integer = 0 to ErrLogMessageCount-1
err = pdf.GetErrLogMessage(i)
MsgBox err.Message
next
// No fatal error occurred?
if pdf.HaveOpenDoc then
// We write the output file into the current directory.
// OK, now we can open the output file.
dim f as FolderItem = SpecialFolder.Desktop.Child("Table with Listbox.pdf")
if not pdf.OpenOutputFile(f) then
MsgBox "Failed to open output file!"
end if
call pdf.CloseFile
f.launch
end if
End EventHandler
End Control