[code]// new PDF environment
Dim pdf As New MyDynapdfMBS
// create a new PDF file
Dim f As FolderItem = SpecialFolder.Desktop.Child(“report.pdf”)
// get graphics for a page
Dim g As Graphics = pdf.PageGraphics
// now get report
Dim rpt As New NameReport
// and a printer setup
Dim ps As New PrinterSetup
// run report
If rpt.Run(PrintableListBox, ps) Then
If rpt.Document <> Nil Then
// let it output to PDF
// close it
By using PageGraphics as Graphics, you can easily use Xojo’s drawing commands for PDF pages and have your application output it’s drawing not just to printer, but also to PDF files.
See blog post:
- Create a PDF with PageGraphics and DynaPDF
- Graphics class for DynaPDF
- Xojo reports with backgrounds on PDF
Code above is intentionally kept brief as all error checking is skipped. If used in real world, you may need to check e.g. if CreateNewPDF returns an error as the file could not be created.
Please do not hesitate to contact us with your questions.