LostKobrakai Posted August 28, 2014 Share Posted August 28, 2014 Hi there, a client of me asked, if it would be possible to automatically generate a pdf invoice after someone ordered something on their simple online shop (no online payment). Does someone know a simple way to accomplish this. The best would be to have some kind of pattern file where just some variables get changed. Link to comment Share on other sites More sharing options...
netcarver Posted August 28, 2014 Share Posted August 28, 2014 A couple of things spring to mind. Firstly there is Ryan's Hanna Code module. Secondly, there's my Tag Parser module. There are probably other ways to do it too - but these were the first that came to me. Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 28, 2014 Author Share Posted August 28, 2014 Thanks for your input, but I don't see how these should help me generating a pdf? Link to comment Share on other sites More sharing options...
adrian Posted August 28, 2014 Share Posted August 28, 2014 There are lots of PHP libraries for creating PDFs dynamically. mPDF seems pretty popular these days: http://www.mpdf1.com/mpdf/ Also check out this guide for using it with PW: https://processwire.com/talk/topic/7025-how-to-create-pdfs-with-pw-and-mpdf/ 2 Link to comment Share on other sites More sharing options...
reems Posted August 28, 2014 Share Posted August 28, 2014 Indeed mpdf came to my mind also. Works easy. Check by example for html to pdf And afcourse the Processwire Pages2Pdf Module If your are able to create a pagetemplate with which you can generate the invoice as html page, converting it to pdf wouldn't be a problem. It's created serverside, so automatic emailing it to the buyer is also possible. 2 Link to comment Share on other sites More sharing options...
netcarver Posted August 28, 2014 Share Posted August 28, 2014 Hi LK, I was looking at this bit of your issue. The best would be to have some kind of pattern file where just some variables get changed. Both of the modules I suggested allow variable substitutions. I believe adrian and reems have the pdf-generation part of your question covered. Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 28, 2014 Author Share Posted August 28, 2014 @ netcarver What I actually meant is that I would prefere a way, where a external created base pdf is altered by the code instead of recreating the whole file. Link to comment Share on other sites More sharing options...
OrganizedFellow Posted August 28, 2014 Share Posted August 28, 2014 I had a client ask me the other day if I could recreate an old PDF document. It's a couple years old and there are a few things they want to have changed. I don't even know HOW to create a PDF, I was thinking Microsoft Word would have some sort of "Save to PDF" feature, or even Google Docs. Naturally it would be simpler and "WOW FANTASTIC" to autogenerate a PDF from a ProcessWire page Link to comment Share on other sites More sharing options...
reems Posted August 28, 2014 Share Posted August 28, 2014 @LostKobrakaiWith mpdf you can also use an existing podf document as template. That comes very close to what you want. Check Importing files & templates @OrganizedFellowI think the Processwire module Page2Pdf would do the trick. That module also uses the mpdf library. 3 Link to comment Share on other sites More sharing options...
Wanze Posted August 28, 2014 Share Posted August 28, 2014 I'd go with a PDF library like mpdf or tcpdf which create your files serverside - they all are similair (depending on the same basic library called fpdf). If you can create your invoice in HTML, you should try the mpdf library, simply because the support of converting HTML/CSS to a PDF file is really nice. If you install my Pages2Pdf module, you have a separate module called WirePDF that is a wrapper around the mpdf library, optimized for ProcessWire. Here is a readme how you could use the module to save/download a PDF file from HTML markup or a ProcessWire template: https://github.com/wanze/Pages2Pdf#wirepdf 3 Link to comment Share on other sites More sharing options...
LostKobrakai Posted August 30, 2014 Author Share Posted August 30, 2014 Thanks for you inputs, I'll see how detailed / typographically perfect their invoice should be and then decide further. Link to comment Share on other sites More sharing options...
Recommended Posts