Hola, estoy trabajando en Xojo2017r1.1 con complementos MBS instalados (estoy trabajando en esta versión debido a que me dijeron que revisara un proyecto anterior).
Me asignaron hacer un botón que guarda el contenido de un WebListBox en un .pdf. Utilicé el complemento DynaPDF para hacerlo posible, y hasta ahora descargué el archivo pero está dañado/vacío, y en xojo obtengo el error “NilObjectException”.
Dim f as FolderItem = SpecialFolder.Desktop.child("test2.pdf")
Dim pdfOut As TextOutputStream = TextOutputStream.Create(f)
Dim pdf as MyDynaPDFMBS
dim intX, intY as integer
dim TableWidth as integer = 2000
'call pdf.SetFont("Helvetica", 12)
// creates table
dim ColumnCount as integer = lb.ColumnCount
const AllColumns = -1
const AllRows = -1
dim ColumnWidths() as Double
redim ColumnWidths(ColumnCount-1)
'Counts columns
dim i as integer
dim strColWidths() As string
dim s as string
s = lb.ColumnWidths
strColWidths = s.Split(",")
dim bolCol() As Boolean
redim bolCol(strColWidths.Ubound)
dim colsVisible as integer
for i=0 to lb.ColumnCount - 1
if trim(strColWidths(i))="*" or strColWidths(i).val <> 0 then
colsVisible =colsVisible +1
if trim(strColWidths(i))="*" then
ColumnWidths(colsVisible-1) = -1
else
ColumnWidths(colsVisible-1) = strColWidths(i).val
end if
bolCol(i) = True
else
bolCol(i) = False
end if
next i
dim SumColumnWidth as Double
for Column as integer = 0 to colsVisible-1
if ColumnWidths(Column) > 0 then
SumColumnWidth = SumColumnWidth + ColumnWidths(Column)
end if
next
for i=0 to lb.ColumnCount - 1
if ColumnWidths(i) = -1 then
ColumnWidths(i) = lb.Width - SumColumnWidth
SumColumnWidth = SumColumnWidth + ColumnWidths(i)
exit for
end if
next i
dim tbl as DynaPDFTableMBS = pdf.CreateTable(lb.ColumnCount, colsvisible, TableWidth, 100.0)
call tbl.SetBorderWidth(AllRows, AllColumns, 1.0, 1.0, 1.0, 1.0)
'call tbl.SetFont(AllRows, AllColumns, "Helvetica", pdf.kfsNone, false, pdf.kcpUnicode)
call tbl.SetGridWidth( 1.0, 1.0)
call tbl.SetGridHorizontalColor(100, 100, 100)
call tbl.SetGridVerticalColor(100, 100, 100)
call tbl.SetBorderColor(AllRows, AllColumns, 100, 100, 100)
// add header row
dim rowNum as integer = tbl.AddRow
call tbl.SetFlags rowNum, -1, tbl.ktfHeaderRow
dim tblColumn as integer
for Column as integer = 0 to ColumnCount-1
if bolcol(Column) then
dim t as string = lb.Heading(Column)
call tbl.SetCellText rowNum, tblColumn, pdf.ktaLeft, tbl.kcoCenter, t
tblColumn = tblColumn +1
end if
next
// now fill all the cells
dim c as integer = lb.ColumnCount-1
for Row as integer = 0 to c
tblColumn = 0
rowNum = tbl.AddRow
for Column as integer = 0 to ColumnCount-1
if bolcol(Column) then
dim AlignMent as integer = pdf.ktaLeft
'Select case lb.ColumnAlignment(column)
'
'case lb.AlignCenter
'
'AlignMent = pdf.ktaCenter
'
'case lb.AlignRight
'
'AlignMent = pdf.ktaRight
'
'end Select
dim t as string = lb.Cell(row, Column)
call tbl.SetCellText rowNum, tblColumn, AlignMent, tbl.kcoCenter, t
tblColumn = tblColumn +1
end if
next
next
dim dblf as Double
dblf = TableWidth / SumColumnWidth
for Column as integer = 0 to colsVisible-1
ColumnWidths(Column) = ColumnWidths(Column) * dblf
call tbl.SetColWidth(Column, ColumnWidths(Column), false)
next
dim intNewY as integer
intNewY = intY + tbl.GetNumRows * 15
// Draw the table now
call tbl.DrawTable(30.0, intY, 0)
while tbl.HaveMore
call pdf.EndPage
call pdf.Append
call tbl.DrawTable(30.0, 50.0, 0)
wend
'Return intNewY
Si hay alguien que pueda echarme una mano, se lo agradeceré enormemente.