« MBS Xojo Plugins, ver… | Home | Drawing with DirectDr… »

Xojo reports with backgrounds on PDF


Did you know that you can use our DynaPDF graphics class integration in our MBS Xojo DynaPDF Plugin with the Xojo's report engine and output your reports as PDF files?

And while you are using DynaPDF, enjoy all the other features like importing existing pages and using them as background. This allows your application to take a PDF created by your user to put behind the reports to customize them.

Of course you can also use DynaPDF drawing functions to draw the report yourself. Or maybe better use DynaPDFTableMBS class to create tables for the layout. We have an excellent invoices examples for this.

To add a background, you can just drop in this code to load a PDF page from a template PDF instead of the normal append call to create a new blank PDF page:

// optionally put a background in the PDF Dim fi As FolderItem = SpecialFolder.Desktop.Child("template.pdf") If fi <> Nil And fi.Exists Then // ask plugin to ignore clearRect call from Xojo, so we see what's behind report pdf.ClearRectMode = pdf.kClearRectModeIgnoreBig Call pdf.OpenImportFile(fi) // needs Lite 'Call pdf.ImportPDFFile // needs Lite Call pdf.ImportPDFPage(1) // needs Pro If pdf.GetPageCount = 1 Then // okay Call pdf.EditPage(1) Else // import failed? Call pdf.Append End If Else Call pdf.Append End If

As you see we have to set our ClearRectMode property to ignore any ClearRect call which would clear the page. Otherwise the background is replaced with a white rectangle. The property is new in version 20.2 of our MBS Xojo DynaPDF Plugin.

See also Graphics class for DynaPDF and Create a PDF with PageGraphics and DynaPDF on our blog.

Please do not hesitate to contact us with your questions.

The biggest plugin in space...
12 06 20 - 17:11