Page 1 of 1

PHP - Mail Merge type functionality

Posted: Thu Sep 16, 2010 1:16 pm
by kmr_guy
Hello,
Any help on the following would be greatly appreciated.

Problem: We have many templates of Letters, Statements, Invoices, etc. that are in either MS Word or PDF format. We need the ability to dynamically merge data into these templates. The merged data could vary in size, so the document would need to adjust dynamically based on the merged data. The volume can be anywhere from 1 - 15,000 documents (1 - 500,000 pages). Our operating system is IBM i/OS and we use PHP as our front-end programming language. It seems that we are limited in some of the 3rd party products that may be able to handle this requirement due to the operating system and/or use of PHP. Have tried FDPF and TCPDF but doesn't have all of the functionality we need. Read that PDFLib can do what we need, however it's not supported for IBM i/OS and PHP.

Real World Example: A Bank has 100,000 customers. Each customer gets a monthly statement showing them their transactions for the month and additional dynamic information relating to their account. The bank prints and mails these statements, emails a PDF copy, and allows the customer to access their statement online via a web page. What technology does the bank use to handle all of the above quickly, efficiently, and in high quality output?

The solution must be able to do the following (not in any specific order)
1) Run on IBM i/OS
2) Easily integrate with PHP
3) Handle high volume processing
4) Have similar functionality to MS Mail Merge (allow varying size of dynamic data)
5) Templates can be in MS Word or PDF format
6) High Quality output
7) Easily printable by either sending directly to a printer queue or easily printable from opening PDF
8 ) Run "On-demand" or in batch processing

Thanks very much for any help or advice.

Mike

Re: PHP - Mail Merge type functionality

Posted: Sat Sep 18, 2010 7:01 pm
by mecha_godzilla
I'll try and get the ball rolling with some uninformed comments...

I'm fairly ignorant about i/OS but it seems pretty unlikely that you'll find something like PDFlib as an executable ready to run on your specialist IBM hardware/distribution, so your options would seem to be limited to what the PHP interpreter provided by IBM is capable of. Of course, if you have access to source code you can always try compiling other applications to work on your platform.

The main issue with using something like FPDF would really be performance related I suspect. If you need any functionality not provided by FPDF you can always write a set of custom classes to make it do what you need. FPDF (and by association, it's user-added modules) are very comprehensive - in particular, the HTML-to-PDF module has a lot of potential - but the onus is really on you to extend it if it doesn't meet your needs. I'm working on an application at the moment that 'mail merges' information from a database into a standard PDF template and the code I'm using straight from the FPDF site does this without any problems. I would suggest though - if at all possible - that for convenience's sake you shift everything over to PDFs. Not only are they more amenable to script processing than Word documents but they are better supported across all the main OSs and are not really thought of as being 'editable' either. PDFs also give you exact control over how the document will appears when it's printed.

As to your other points:

To cope with the high volume of documents that you have to generate, you'd really need to concentrate on optimising the PHP run-time environment, especially in respect of compiling your applications into byte-code (you'll need to look at what Zend Server can do for you in this respect). PHP also provides you with access to any other applications on the system via functions like exec() and this enables you to shift the batch processing into shell scripts, etc.

As to how banks handle all of this, the answer is still (I suspect) by using mainframes. If performance and system-level access is important, then they could be using anything from COBOL, C, C++ or Java to a whole range of other languages - but PHP probably wouldn't be one of them :) Most financial and insurance companies that I know of have in-house developers - either to create new applications or extend existing ones. Given that your application is almost completely back-end based, is there any reason why PHP has specifically been chosen? As this page demonstrates, you have a wide range of other options:

http://www-03.ibm.com/systems/power/sof ... tures.html

HTH,

Mecha Godzilla

Re: PHP - Mail Merge type functionality

Posted: Tue Sep 21, 2010 11:22 pm
by almedajohnson
That's really interesting thread. I really liked the way mecha have replied to the questions and explained it. I am new to the PHP and that's why I always try to get something new and informative. I got the today's lesson.