4

I have a website that deals with a huge amount of data in the form of customer's information and the things that they have ordered for a day. Now since this particular site have hundreds of client and everyday each customer have inbetween 5-20 orders.

The owner of the site wants a page which contains the customer delivery info the their order list in each separate page so that when they can print it and stick it on the package. However each new client info needs to start in a new page.

enter image description here

eg:

--Start Page ---

Customer 1 Delivery info

Customer 1 Order info

"Some empty space here if order info is short"

----Next Page----

Customer 2 Delivery info

Customer 2 Order info

------Next Page ---

Customer 2 Order info continued (this could be only one few lines and could leave a large empty space below)

"Some empty space here"

----Next Page---

Customer 3 ...


When I treid to output the plain html and then print the page, the page was all messed up so I solved it generating PDF (I am using MPDF53) and there in lies my problem.

The problem is that it takes a long time to generate the PDF and eats up lot of system resources. I already had to increase the server execution time for it to run successfully (from default 30 sec). Now as the customers grows, the list will keep on growing and so will the execution time. If a 100 customer list can go beyond 30 seconds I wonder what will it be when it reaches 1000 or more.

The print page itself donot contain any graphics and the sql query are generated fairly quickly (this is because when I was outputting as html the page would load up pretty quickly).

Is there any alternate way to have a page break in html document so that when I print this page it follows that page break correctly or anyother way that can speed the pdf generation or do I simply have to bear with the long executing time.

Edit: One problem with using just html document even with page break would be saving it for later records or reference.

Thanks

Kaushtuv
  • 479
  • 5
  • 17
  • Why don't you try other pdf libraries? – Ali Mar 12 '12 at 01:03
  • If other pdf libraries are not available for php (i have no experience with php) I am sure you can build a simple service in python or ... with efficient libraries and use them with a REST api or some other api. – Ali Mar 12 '12 at 01:05
  • i would use html pdf creation is slow, so unless you really need it, dont use it –  Mar 12 '12 at 01:08

2 Answers2

4

I had the same problem many years ago, and ended up relying on the CSS page-break-after property (see here for more info). You could try generating the pages in HTML, and adding page-break-after:always to the div that contains a customer's information.

I wouldn't rely on this for highly reliable compatibility across all users and platforms, but if it's an in-house application then you can probably get away with specifying that they need to use a modern version of Firefox, Chrome, or IE.

octern
  • 4,825
  • 21
  • 38
  • It can be an alternative, but like said in my edit (sorry missed this bit earlier) the client may want to keep the files as records. – Kaushtuv Mar 12 '12 at 03:37
  • They could download a copy of the HTML file. You could also write it out to a datestamped logfile on the server so they could reference it even if they didn't save a copy at the time. – octern Mar 12 '12 at 04:49
0

1) You could try alternatives for generating PDFs: Convert HTML + CSS to PDF with PHP? and Which one is the best PDF-API for PHP?

2) You could consider using LaTeX: http://www.mayer.dial.pipex.com/tex.htm

Community
  • 1
  • 1
theonova
  • 21
  • 2