views:

5708

answers:

13

I'm looking for something that works in PHP and is similar to crystal reports. I basically need to have a layout setup that means I can output invoices just by inserting the data, and then send it to a printer.

The closest I've found so far is PDFB, but It's a bit of a pain as it needs to have precise positioning.

I'd like to have something that could generate an invoice based on a template (preferably XML based) and then output it to a form easy for us to print (PostScript would be nice!)

It needs to have support for barcodes too (though these can be generated as a GD image)

Another requirement is that this must be FLOSS

+1  A: 

hm.. i had the same problem at my current project and i ended up using crystal reports and calling the report with an asp.net web service written in c#. the web service is nothing to complex and you can still use all the features of crystal reports. i dont think that you will find any report engine that is completely based on php that can be compared to crystal reports... i havent been able to find one yet...

Gushiken
+1  A: 

If you have server access you might also like to go for XSL Formatting Objects through Apache FOP. XSL-FO is XML based and supports alot of output formats including PostScript and PDF

Martijn Laarman
Would love to hear why my answer was downvoted.
Martijn Laarman
+5  A: 

Use XML + XSL:FO with Apache FOP via PHP-JavaBridge.

Here is how: http://wiki.apache.org/xmlgraphics-fop/HowTo/PHPJavaBridge

PostScript would be nice!

Many PostScript printers understand PDF too.

vartec
If your postscript printer does _not_ understand PDF, have a look at `gs(1)` and its helper application `pdf2ps(1)`.
gnud
+3  A: 

Check out PHPReports, it may fit your needs.

lsdr
+1  A: 

I ran into the same problem about a year ago. After searching all over for an existing solution I didn't find one, so I wrote a slimmed-down crystal reports using Zend Framework's PDF generation library. I had to heavily adapt their library to support grouped objects, repeating sections and templates. It worked, but it was really clunky, and if I had to do it again, I would find a way to bridge php to crystal reports, either through a web service like Gushiken said, or by calling a command-line app. CPAN has a Perl interface to C.R.: Win32::OLE::CrystalRuntime::Application .

If a PHP solution has been released in the past year, I doubt it is mature enough to compare to C.R. Don't waste your time pulling your hair out -- go with what works. Time is expensive. Software ain't.

redmoskito
+2  A: 

If you manage to call a Java application in your php-environment (which in general should be possible) JasperReports maybe the thing you are looking for:

Ansgar
Yeah, this is what we're using now, as we use Jasper in other places.
Mez
+1  A: 

I've used Spreadsheet_Excel_Writer in PHP, and it's good enough. Not WYSIWYG, but it does generate XSL files, and I'm happy with it. Afterwards, you can use OpenOffice macro to convert the document to PDF. It works from command line, ergo, it works from PHP scripts too.

Or here's an even better way.

Use OpenOffice to write a Smarty template. Smarty is a cool templating engine for PHP, I recommend it for this purpose. Then generate pure HTML using PHP with Smarty. Finally, just convert the generated HTML into PDF using aforementioned method.

Reporting Revolutionized (tm).

EDIT Jun6 2009 Modded down? Ah, nevermind.

Anyways, this method works on a headless server without running X11. I've taken the script from the mentioned link (except I put it in preexisting collection "Standard" instead of "DannysLibrary") and then I've ran this command from Windows machine using PuTTY, and X was shut down on remote machine, and DISPLAY variable was not set, and ... well, in any case, there's no way OOo could find X11 to connect to.

$ openoffice.org -invisible -headless "macro:///Standard.Conversion.ConvertWordToPDF(`pwd`/logaritamska.doc)"

This works and I'm sure this would work great for anyone who'd need conversion from another format into PDF, including production of printable reports from HTML. By editing the macro you could, perhaps, even get OOo to read directly from stdin or from your temporary service URL, and output into predefined file. The script on the link is quite simple once you have the elementary code to expand.

Summary:

  • generate reports as XLS or HTML
  • convert them
  • even though it's OOo, it works on headless machines

EDIT Jun 9 2009 I've tried to implement an online converter this way. You should make PHP run under the same user under which you created macros. This user apparently cannot be www-data. I've tried to use suphp, but for some reason it didn't change the user properly (posix_getuid() kept returning 33 which is www-data). I'll edit this once I fix this.

EDIT Jun 26 2009 Guess it took me a while to report back. Yes, this works with suphp. I'm however not in position to show it live, since the only server I have runs a relatively critical web app which didn't have professional security auditing. This means one of the things we depend on to protect the backend is that the user under which frontend runs is a very very unprivileged user (such as www-data). Don't ask :-)

Hope this helps someone: yes, converting into PDF with OO.o is quite realistic. There's even some remote calling support in OO.o but I didn't study that just for purposes of writing this.

Ivan Vučica
This has to be automated on a gui-less server. This isn't really an appropriate solution.
Mez
WRONG! This works on a headless server. I've added exact command to my comment.
Ivan Vučica
A: 

Have a look at siwapp.org, it is opensource invoicing application based on Symphony Framework, it is in early beta but very promising.

Nazariy
+4  A: 

I have used the eclpse in php: "BIRT Project"

http://www.eclipse.org/birt/phoenix/

You design your report in Eclipse. Then upload it to your server (it must be running tomcat) I know. Then you can call that report from your php application you can send the parameters to the report through the query string:

/myreport.birt?param=var&param2=var2

We have a 4 year application working like this so far. Around a 100 reports and it works really well.

Of course it is open source.

Good luck

elviejo
I agree that BIRT is the way to go. See this developerWorks article showing how to integrate BIRT with PHP using WebSphere sMash: http://www.ibm.com/developerworks/websphere/techjournal/0903_phillips
rewbs
A: 

Free possible solutions that works in PHP for report generation

  1. PHPExcel oops based library for exporting reports in various formats.
  2. JasperReports java based library XML based (not well documented for PHP) but works

there are few other as well , but they don't really catch up my attention

Ish Kumar
A: 

I'm looking for something that works in PHP and is similar to crystal reports. I basically need to have convert my php page result to pdf format for display and print .

A: 

Try Tufat

I just happen to see that ..may be it will help you. However there is a free version is available for you to test.

You will like it .. Please share your copy.

Ratheesh R
A: 

We're now using iReport and a Java Bridge

Mez