We are integrating DynaPDF with the Graphics class in Xojo. You can get a graphics object to draw into the current page via normal graphics class methods. The code looks like this:
Dim g as graphics = pdf.PageGraphics
Technically we create a temporary picture with a subclassed graphics class and give you the graphics object from the picture. You can get the temporary picture with PageGraphicsPicture property. All draws go both into the picture and the PDF page:?
Dim p as picture = pdf.PageGraphicsPicture?
We support normal drawing commands in graphics class and the usual properties. Draw/Fill Oval/Rect/RoundRect/Line/Polygon will just work. DrawString draws text for single and multi line. StringHeight and StringWidth measure text via DynaPDF functions, so the result may be different than in a picture, but you get the right values needed for the PDF output. DrawPicture can draw picture with alpha channel and masks if needed. NextPage method will close current page and make a new one. Or you implement NextPage event to do this yourself. Then you can import existing page as background.
We support vector graphics classes (Object2D) and drawObject command. Most properties should work and this includes transparency and rotation.
As the report engine is built on Object2D, the report engine can output to PDF via our graphics class.
This works in all Xojo versions (And Real Studio), with all DynaPDF editions and come soon with next 19.2 prerelease.
Great work Christian. Would you please share your XDC info to DynaPDF to with us who can’t be there? Would be nice.
Does this also apply to setting colors in Xojo format with alpha value?
- Coming later this year
- Full unicode support
- Automatic Font Substitution
- ZUGFeRD 2.0 (standard for invoices as PDF)
- Verify digital signatures
that was the slide for DynaPDF 5.
Super nice. Does your bridge auto translates Xojo’ 72 DPI coordinates to DynaPDF?
PDF also uses 72dpi grid for drawing unless you change it.
Here a nice short example on how to draw a PDF with our new PageGraphics property in DynaPDFMBS class:
[code]Dim pdf As New DynapdfMBS
// please subclass DynapdfMBS to implement error event
Dim f As FolderItem = SpecialFolder.Desktop.Child(“DynaPDF Graphics.pdf”)
// For this example you can use a Starter, Lite, Pro or Enterprise License
// Create new PDF. Use f = nil for in-memory PDF
// append a new page, so we have an open page
// get graphics object to draw on the page
Dim g As Graphics = pdf.PageGraphics
// draw as usual
g.DrawString “Hello World”, 105, 100
g.DrawRect 100, 80, 100, 100
// close page and file
// for in-memory PDF, use GetBuffer here to grab it.
'Dim PDFData As String = pdf.GetBuffer[/code]
You can put the actual drawing code into a method with g as graphics parameter and than call it on several places. e.g. call it from Canvas.Paint event to show it in a window, call it with graphics from OpenPrinterDialog to draw in printing context or call it with PageGraphics to draw into a PDF document.
again this is something else amazing that @Christian Schmitz and company has done to make our lives easier. thank you!
Anyone tried it and can report some issues to be fixed before 19.2 release?
We made a blog article for the Xojo blog:
Using the Graphics Class to Create PDF Documents
MBS Xojo Plugins are part of the sale this weekend on the Xojo store.
A few fixes are coming for next version to improve this.
We’ll add FillPath support and ClearRectangle method. Those were missing.
A starter license for the MBS Xojo DynaPDF Plugin is included in OmegaBundle 2020 .