PDF generation with kerning

337 views
Skip to first unread message

James McGlinn

unread,
Mar 6, 2009, 12:23:03 AM3/6/09
to PHP Users Group List Group List
Hi guys,

There are a number of really good (and free) PDF generation libraries
for PHP - I've been using FPDF/FPDI for a while now.

Unfortunately FPDF doesn't support kerning when drawing text. Neither
it would seem do TCPDF, Haru PDF or the R&OS PDF class.

Does anyone know of a PDF generation library in PHP that does support
font kerning? I also need it to be able to import PDF templates (a la
PDI) and to be able to rotate text being drawn.

PDFLib does all this and more, but at US$2000 per server it's a bit
pricey when all I need is that one feature.


Kind regards,
James McGlinn
__________________________________
CTO
Eventfinder Limited
Suite 106, Heards Building
2 Ruskin Street, Parnell, Auckland 1052
Phone: +649 365 2342
Mobile: +6421 633 234

james....@eventfinder.co.nz | www.eventfinder.co.nz


eventfinder.png

Aaron Cooper

unread,
Mar 8, 2009, 2:58:07 PM3/8/09
to nzp...@googlegroups.com
Hi James,

I remember kerning was on Zend Framework's Zend_PDF class TODO list last
year. I'm not sure if it has made it through yet, and definately can't find
any reference to it in the official docs. But might be worth digging a
little deeper on ZF.

Cheers
Aaron
--------------------------------------------------------------------------------


>
>
>

James McGlinn

unread,
Mar 8, 2009, 3:29:48 PM3/8/09
to nzp...@googlegroups.com
On 9/03/2009, at 7:58 AM, Aaron Cooper wrote:

> I remember kerning was on Zend Framework's Zend_PDF class TODO list
> last
> year. I'm not sure if it has made it through yet, and definately
> can't find
> any reference to it in the official docs. But might be worth digging a
> little deeper on ZF.

Thanks Aaron, it does look like it's been suggested as a potential
future enhancement for Zend_PDF but doesn't appear to have made it to
the top of the list just yet.

In the meantime I'm extracting the kerning data out of the truetype
files and setting the character spacing manually for each letter.
It's a bit of a hack and makes alignment more challenging, but does
the trick.

lenz

unread,
Mar 8, 2009, 6:44:29 PM3/8/09
to nzp...@googlegroups.com
i worked with a (admittedly ugly) hack with generating Latex and then compile a PDF out of that. this worked fine for me but is ages ago and i have no real pointer to it. if you are unfamiliar with tex it might be not a good option, if you are, do some templateing and scripting and you should get what you want.

cheers
lenz
--
iWantMyName.com
painless domain registration (finally)

James McGlinn

unread,
Mar 8, 2009, 8:37:01 PM3/8/09
to nzp...@googlegroups.com
On 9/03/2009, at 11:44 AM, lenz wrote:

> i worked with a (admittedly ugly) hack with generating Latex and
> then compile a PDF out of that. this worked fine for me but is ages
> ago and i have no real pointer to it. if you are unfamiliar with tex
> it might be not a good option, if you are, do some templateing and
> scripting and you should get what you want.

Thanks Lenz, I haven't used TeX but investigated doing the same thing
with the pslib extension. Ended up deciding against it just because
it looked immature (some functions are documented but unimplemented)
and I wasn't sure I'd end up with a better solution after writing the
EPS to file, converting to PDF, then reading back in. Sometimes
better the devil you know!

Reply all
Reply to author
Forward
0 new messages