PDF alternative for dynamically generated document with page breaks

I have a website that processes a huge amount of data in the form of information about customers and what they ordered during the day. Now, since this particular site has hundreds of customers and every day, each customer has 5-20 intermediate orders.

The site owner wants a page containing information about customer delivery, their list of orders on each individual page, so that they can print it and paste it on it. However, each new customer information must begin on a new page.

enter image description here

eg:

- Start page ---

Customer 1 Shipping Information

Customer 1 Order Information

"Some empty space here if the order information is short."

---- Next page ----

Customer 2 Shipping Information

Customer 2 Order Information

------ Next page ---

Customer 2 Ordering information continued (it could be just a few lines and could leave a lot of empty space below)

"Some empty space here"

---- Next page ---

Client 3 ...


When I try to output a simple html and then print the page, the page was corrupted, so I decided to generate PDF (I use MPDF53), and that is my problem there.

The problem is that it takes a lot of time and a lot of system resources to create a PDF file. I already had to increase the server runtime so that it runs successfully (30 seconds by default). Now that customers are growing, the list will continue to grow, as well as the lead time. If the list of 100 clients can exceed 30 seconds, I wonder what will happen when it reaches 1000 or more.

On the print page itself, containing any graphics, and sql query are generated quite quickly (this is because when I output as html, the page loaded quickly).

Is there an alternative way to break a page in an html document, so when I print this page it follows that the page breaks correctly or in any other way that can speed up the creation of PDF files, or I just have to deal with a long lead time.

Edit: One problem using only an html document, even if the page breaks, will save it for future posts or links.

thanks

+4
source share
2 answers

I had the same problem many years ago and ended up relying on the CSS-break-after property (see here for more information). You can try creating pages in HTML and add page-break-after:always to the div that contains the client information.

I would not rely on this for highly reliable compatibility for all users and platforms, but if this is a native application, then you can probably leave by indicating that they need to use a modern version of Firefox, Chrome or IE.

+4
source

1) You can try alternatives for creating PDF files: Convert HTML + CSS to PDF with PHP? And which one is the best PDF API for PHP?

2) You can use LaTeX: http://www.mayer.dial.pipex.com/tex.htm

0
source

Source: https://habr.com/ru/post/1400908/


All Articles