The Register® — Biting the hand that feeds IT

Build your PDF and Excel reports with PHP

Si

If you can't use PECL 

Thumb Up

If you can't use PECL I highly recommend the FPDF class here: http://www.fpdf.org/

It's written entirely in PHP so you don't need to re-compile or install anything special to use it and it works on most versions of PHP from 4 onwards (it probably works with PHP3 but I've not tried it).

Anonymous Coward

Dont wanna steal your thunder... 

Coat

You could alway make it universally programtically available for excel by just making a plain html table and generate the file with a .xls extention... works perfectly!

:p

zac spitzer

That;s only basic PDF 

Stop

But if you really want to work with PDF's you cannot beat Coldfusion 8 from Adobe. You can simply take Full blown HTML with CSS etc and create a PDF directly, plus there is deep support for doing all sorts of things with PDF.

It's not open source, but if you have anything beyond basic PDF text to do or you need great looking PDF's, the cost of a standard CF license will be easily recovered

Uwe Dippel

And the *nix version is ? 

or do you only entertain Windows boxen ?

Martin Beckett

html2pdf 

IT Angle

Or create html (with css) and use html2pdf from php

Taran Ablitt

LaTeX? 

LaTex is how I generate PDFs from PHP. Output the LaTex, process into PDF then serve up and depending on the case, cache for future access. Works very well for me.

Calum

ClibPDF Depreciated 

Looks like ClibPDF is depreciated...

http://de3.php.net/manual/en/ref.cpdf.php

Uwe - if you mean the *nix version of this article then its identical, just different directory locations, as the scripting is all php based. however if you are talking bout the file formats then you may have a point but there is a pdf reader and open office for linux.

Pie Man

Apache POI with PHP-Java Bridge 

Thumb Up

Excel_Spreadsheet_Writer is still fairly basic. If you need more functionality, try using Apache POI from PHP. It'a actually a Java Application, but it's methods can easily be accessed from PHP using either the free or Zend PHP-Java bridge. If anyone's interested in more information james2 /at/ jfirth /point/ net

Not That Andrew

Lets not forget pdftk 

Linux

The swiss army death ray of pdf toolkits.

George

So last year... 

Thumb Down

This is not the best article on ElReg.

The new way surely has to be Zend Framework for PDF writing. PEAR works, but ZF is superb and well structured.

http://framework.zend.com/

Andrew Moore

Another vote for ZF here. 

Thumb Up

Type your comment here — plain text only, no HTML

Anonymous Coward

How big? 

Stop

Excuse me but what size did you say A4 was?

Martin Beckett

re: How big 

Coat

1.04 * 1.47 mFurlong

A J Stiles

Been There, Done That 

Heart

I've already been generating PDF files out of Perl for some time now, just by generating PostScript (OK, so I know a bit of PostScript ..... wouldn't call myself anything like fluent, but I know how to draw simple shapes and stick text on a page) and piping it through pdf2ps. You can even insert images saved as EPS straight into the stream. It doesn't half look impressive (although that's probably more to do with the perception of PDF as being used only for highly "official" documents). As a final touch, I even detected the user's OS and offered a link to an appropriate, non-Adobe PDF reader (healthy competition is a wonderful thing).

Also, if you generate a simple CSV file but give it the extension XLS, Excel will load it without missing a beat (Office doesn't really go for file extensions). You can even provide a second link to download the same file with a CSV extension (for Open Source users), so as not to scare anyone into thinking they absolutely need proprietary software.

Shelon Padmore

Try phpPDF 

Consider phpPDF. It's quite good

- Shelon Padmore