0

I have created a site with a custom module built on top of OpenCart. It allows you to design a business card, brochure, or post card online (something like vistaprint but simpler) and generates a print ready file.

One of the requested features was a mail merge type feature for post cards. Basically the customer would create their design, then upload a csv file of the names and addresses they want the document mailed to.

My thought was after the order was placed a script on the server would go through the csv file, and create an image for each row. Basically inserting the mailing address onto the graphic and saving it as a copy. Once it was done with them it would bundle them into a pdf and send the printer a link to download the file.

That will work great if they are sending it to 100 people or less, but if they want to mail it to 10,000 people I don't see it working.

Does anyone have any experience generating a mass amount of graphics and giant pdfs? If so I would love their advice on how to implement it.

I have full control of the server, and can install or modify any software on it. It is Cent OS, with PHP, MySQL, and the works. I do not have any extra pdf extensions installed as I haven't needed them yet, but I can add them.

Other Notes:

- The resolution will be at 300dpi. Meaning each page of the pdf will be as much as 2,550 x 3,300px
- The final product doesn't have to be a pdf, it just needs to be a single file and printable
- I am currently rendering the graphics as a jpg or png

I do plan to post the module on OpenCarts extension directory after I have all of it working, so if it suits anyones needs it will be there once it is all working properly.

Developer Gee
  • 362
  • 3
  • 12
  • [Prince XML](http://www.princexml.com) is a good tool to get PDFs out of. Not free but I've gotten good results from it. – Orangepill Jun 06 '13 at 04:55
  • You can get a trial of it .... the only drawback is it shows a watermark on the screen version of the resultant pdf (not on the print). It's worth the price tag if you are doing something as heavy as you are with it. – Orangepill Jun 07 '13 at 05:05
  • Thank you for the suggestion. I have not tried that. The $3,800 price tag is a bit of a deterrent. I have been playing with mPDF (http://www.mpdf1.com/mpdf/index.php), which seems to be similar. I can set the bg image of the pdf, which allows me to use the same image over and over. Then I can use plain text to put the address information on top of it. It is a partial solution, not 100% yet. It gives me very reasonable file sizes, a 10,000 page pdf set to 4"x6" at 300dpi ended up at only 10mb. It is still killing the server to process the file (150mb ram and 10 min. to run). – Developer Gee Jun 07 '13 at 05:09
  • My next step is to go through the mPDF code and remove any of the classes/functions that I don't need and see how much of a performance difference it makes. – Developer Gee Jun 07 '13 at 05:09
  • Mail merge on a static background prince may be overkill. Might make sense to pull your processing offline as far as creating the PDF's unless the PDF's are the deliverable. With prince I was getting about 900 12 page books printed 2 up (so 5400 12x18 pages) output every 3 minutes. Variable images, graphs, 9 different languages.... it was a monster. – Orangepill Jun 07 '13 at 05:15
  • each of the files weighed in at about 20mb but that was largely due to the number of variable images and fonts. – Orangepill Jun 07 '13 at 05:18
  • The PDF is the final deliverable. The print shop gets an email with a link to the pdf. They download and print it. Do you remember any of the hardware specs when you were generating the books? I'm curious what hardware it took to do that in 3 minutes. – Developer Gee Jun 07 '13 at 05:23
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/31369/discussion-between-orangepill-and-developer-gee) – Orangepill Jun 07 '13 at 05:23

1 Answers1

0

If you have access to the box install ImageMagick and then use "convert" application.

convert *.jpg pdf/export.pdf -density 960x570 -units PixelsPerInch

http://www.imagemagick.org/script/convert.php

bolbol
  • 325
  • 3
  • 9