« Quickly copy lots of … | Home | FileMaker Conference … »

Tip of day: Save Xojo report to PDF

Yesterday one of the attendees of the conference asked if we could update his Mac app to write a Xojo report to PDF directly. OS X can print to PDF, so we use our MBS Plugin classes to redirect printing to a PDF file with code like this:
Dim ds As New GasDataSet Dim ps As New PrinterSetup Dim rpt As New GasPricesReport 'this is a report editor project item 'set the resolution to 300 DPI for printing ps.MaxHorizontalResolution = 300 ps.MaxVerticalResolution = 300 // change PrinterSetup to point to print to PDF file dim s as new NSPrintInfoMBS s.SetupString = ps.SetupString s.SetSaveDestination SpecialFolder.Desktop.Child("test.pdf") ps.SetupString = s.SetupString // now print report Dim g As Graphics = OpenPrinter(ps) If g <> Nil Then If rpt.Run( ds, ps ) Then 'if the report runs successfully rpt.Document.Print(g) End If End If
As you see we use the NSPrintInfoMBS class to manipulate PrinterSetup's setupString to target the PDF file. The code above is from the modified Gas Reports example coming with Xojo.
30 04 15 - 17:25
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.