DynaPdf Print Listbox Landscape

To print the listbox in landscape format:

call pdf.SetPageCoords pdf.kpcTopDown
call pdf.Append
call pdf.SetOrientationEx 90

but only the first page of a listbox opens in landscape format

you need to repeat call to pdf.SetOrientationEx on each page.

Hi Christian will you please tell me where to enter call pdf. SetOrientationEx 90 to get the landscape in every page?

// setup PDF
dim pdf as new MyDynaPDFMBS
call pdf.CreateNewPDF
call pdf.SetPageCoords(pdf.kpcTopDown)
call pdf.Append

// 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)
// 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)

// Draw the table now
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)

call pdf.EndPage

dim f as FolderItem = SpecialFolder.Desktop.Child(“Table with Listbox.pdf”)

After each call to append function please.

I tried in every possible way but the result is always the same. Only the
the first page is in landscape mode. You can try the example ?

I use similar code, and in my experience it does not change the format after each page.
I dont call pdf.SetOrientationEx more than once while doing a table, either.

When I use DynaPDFMBS to generate output, I have a method I call if there is any chance that the page orientation or size needs to be set for certain, or changed.

I pass in an integer which tells me which page size is required, and a flag that tells me if it should be landscape

The method holds this code:

(Note: DynaPDFMBS does not have constants for A1 or A2, so I added these myself using the known page sizes and calling SetPageWidth/Height explicitly… otherwise I just use the SetPageFormat)

if nPageSize = kpdf_DINA1 or nPageSize = kpdf_DINA2 then
if nPageSize = kpdf_DINA1 then
call pdf.SetPageWidth(1684)
call pdf.SetPageHeight(2384)
end if
if nPageSize = kpdf_DINA2 then
call pdf.SetPageWidth(1191)
call pdf.SetPageHeight(1684)
end if
call pdf.SetPageFormat(nPageSize)
end if
if PageIsLandscape then call pdf.SetOrientationEx(90)

call pdf.SetJPEGQuality(m_theJPGQuality) //compression rate
call pdf.SetDocInfo pdf.kdiProducer, gProgName //global variable, name of my app
call pdf.SetDocInfo pdf.kdiSubject, “” + m_pdfSubject // subject of the PDF
call pdf.SetDocInfo pdf.kdiTitle, m_pdfTitle //title of the pdf
call pdf.SetDocInfo pdf.kdiAuthor, m_pdfAuthor // user name
call pdf.SetFontSelMode(pdf.ksmFamilyName)
call pdf.SetSaveNewImageFormat(false)

OK it works. But the problem was not the code. Mac preview I opened the last document saved on my desktop. I’m sorry

while tbl.HaveMore
call pdf.EndPage
call pdf.Append
call pdf.SetOrientationEx 90 <–
call tbl.DrawTable(50.0, 50.0, 742.0)

Great. Have fun with DynaPDF!

Great product DynaPDF.
It solved all my problems printing.
Tanks for your time