Simple PDF Class

I needed an easy way to create xplat PDF files … and looked at various plugins, classes etc that others have made available for Xojo, and either the cost was too expensive in relation to the project, or they were too complex to just “drop in”.

SOOOOO… that being said. I have begun development of a “Simple PDF” class. This class will be an almost 100% drop in replacement for a Printer Graphics Object. To the point where the properties and methods are IDENTICAL, with the exception of TWO… the constructor accepts more parameters, mostly to compensate for the fact there is no Printer Dialog involved or needed… and a NEW method called SavePDF which places the results in an external file.

Currently I have DRAWLINE, DRAWRECT, DRAWOVAL, DRAWPOLYGON,FILLRECT, FILLOVAL, FILLPOLYGON, FORECOLOR, PENWIDTH, NEXTPAGE,HEIGHT and WIDTH all working (not bad considering I started work on this about 8 hours ago :slight_smile: )

Still to do is DRAWPICTURE, DRAWOBJECT, DRAWROUNDRECT, FILLROUNDRECT, DRAWSTRING, TEXTHEIGHT,TEXTASCENT,STRINGHEIGHT,TEXTASCENT (ie… all of the “text stuff” :frowning: mostly)

simple example of its use

  dim pdf as new classGRAPHICS_PDF
  pdf.ForeColor=&cff0000
  pdf.PenWidth=5
  pdf.DrawLine 10,10,1000,1000
  pdf.NextPage
  pdf.drawrect 100,100,200,200
  pdf.drawoval 100,100,200,200
  pdf.ClearRect 150,150,200,200
  pdf.SavePDF(SpecialFolder.Desktop.child("x.pdf"))

So far only one tiny drawback… The PDF file it creates is not compressed… but hey I haven’t gotten to version 2 yet

How about defining page size?

I use Asher Dunn’s open source PDF classes from ages ago which is OK for my current needs… But I’'m waiting for Xojo’s implementation which has been scheduled for long time.

When complete it will (currently) support US Letter, US Legal, US Ledger and A4 paper sizes, with a default resolution of 72DPI, user configurable to any resolution required…

That’s awesome. I’m looking forward to this if you decide to make it public.

Dave, this is, as Kem said, awesome!! :slight_smile:

This would make a great addition to Xojo! Can’t wait to try it out.

The goal is to beat fpdf. Go fer it.