I spent all yesterday evening adding graphics primitives support into PDFLib.pm, my OO layer over pdflib_pl.pm - the perl module that ships with pdflib. Despite the fact that pdflib isn't quite open source (It's the Aladdin public license), it's probably the best option for producing PDFs in Perl, being XS/C based it's very fast and lightweight.
Unfortunately PAUSE seems to be down, or not responding for me, so you'll have to wait to get your hands on it.
The reason I started hacking on PDFLib again was that I needed string_width (which is a core pdflib function), and once I'd added that I noticed a few other things I wanted to clean up, and then it just started snowballing. I'm at the point now where PDFLib almost covers all of the core pdflib functions, with the exception of some of the linking/embedding options, and the PDI (PDF Import) stuff, which would be nice to have for editing PDFs, but you have to pay for that. I may download the demo though and play with it a bit.
Anyway, I keep digressing...
I need string_width because I'm trying to do something that's proving very hard indeed - how to layout centred or right-aligned text that may or may not mix different fonts, styles and so on. And do it based on a stream (this is from XML, so I may see
I'll have to check out PDFLib.pm and see how it works and if it would be worth it to incorporate it into the software I'm developing. It would probably have to be pretty slick to make it worth it to go back & retrofit the existing code. Does it depend on a specific version? I'm currently using 3.0.3, but might upgrade to 4.x in the future.
Re:Ahhh... pdflib
Matts on 2002-02-06T07:14:51
It uses 4.x I'm afraid.
I'm not sure about "slick", but I much prefer an OO view of the world, where instead of typing PDF_foo($pdf, options), you type $pdf->foo(options). Just makes more sense to me. Plus it takes care of things like ending pages for you so you don't have to - pdflib really doesn't like it if you do something in the wrong order, so PDFLib.pm *tries* to accommodate that.Re:Ahhh... pdflib
ajtaylor on 2002-02-06T09:08:10
Oh well. I'll definitely look into it more if/when I upgrade. Since I haven't bought a license yet, maybe soon is a good time to upgrade.:-) OO certainly makes sense for some things, and I think pdflib is definitely one of them. I'm interested in learning more about the auto page ending feature. Guess it's time to look at the docs, or have you released that code yet?
Re:Ahhh... pdflib
Matts on 2002-02-06T09:54:27
It's on CPAN. Along with the sweeet XML::Handler::AxPoint, which creates PDF presentations from XML.
I'll just note that the string_width() problem is the first running jump onto the waterslide of formatting that ends up with you reimplementing TeX in Perl without the shitty fonts.
--Nat
Re:pdflib++
Matts on 2002-02-06T07:19:04
Hey I *like* the TeX fonts!
Seriously though, I got it working. It was much easier than I thought it would be. I suspect it would be nice to extend it so I could setup some sort of bounding box object, and allow the user to just print into that and have the wrapping sorted. But that's for another day.Re:pdflib++
pdcawley on 2002-02-06T14:59:21
Speaking of which, if anyone has a way of getting TeX to use OpenType fonts (with proper small caps, Old style figures for running text etc), I'd really, really like to know about it...