In Symfony: Is there a way to create pages of PDF files at a time?

I have a Symfony platform with the TWIG template engine. I make 1000 pdf pages inside

<dynamic-page>...content in for-loop...</dynamic-page>` 

However, when writing to ps_facade it gives me an exhaustive fatal error. So is it possible to create this PDF file on 5 pages?

After researching, I found that using a template with a 5-page data cost and then writing to a file should work. But this way I can not add page numbers, since the page number should be 1-1000. My footer code is as follows:

 <placeholders> <footer> <div height="30px" width="100%"> <hr/> <div float="left">Blah Blah</div> <div float="left" margin-left="350px"><page-info format="Page %s of %s"></div> </div> </footer> </placeholders> 
+6
source share
1 answer

You should use messaging for long processes like this . RabbitMQ can do the job.

  • Your user requests for pdf
  • Immediately inform him that his request has been taken into account, and that he will receive an email when this is done, or that he may return later.
  • The consumer sees the work and starts the creation of pdf (it does not have to be in php).

Pros: Since the process is not executed by the web version of php, it has no time limits memory_limit and max_execution If the task is already running, you can tell your user that instead of starting another generation for the same pdf. And since people often refresh the page when they become impatient, it really can be a huge Pro for your server (less CPU usage).

Cons: You will need to set up a messaging server and learn a few things. But is it really con?

+2
source

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


All Articles