Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
reload an iframe in a loop with new content and print with one print command

I want to print a report generated with Symfony and twig worth over 5000 pages. I tried printing with one print command in firefox and chrome but the browser crashes or times out while loading the document.

However, there is another option where I can iterate over an object and for each iteration reload an iframe with new page content and print. How can I do this with one print command without calling the print dialog in each iteration?

This is my scenario:

Option 1:

Symfony Controller:

public function printReports(Request $request, $from, $to) {
   // $bills = ....;
   $all_bills = $bills->loadAll(['from' => $from, 'to' => $to]);
        
   return $this->render('reports/print.all_bills.html.twig', [
       'bill_ids' => $all_bills //$all_bills can result in over 50000 pages
   ]);
}

Twig Template:

{% extends "base.html.twig" %}

{% block body %}
    {% for bill in all_bills %}
        {% include 'pages/bills.front.html.twig' with { info: bill.info } %}  
        {% include 'pages/bills.back.html.twig' with { content: bill.content } %}   
    {% endfor %}
{% endblock %}

Option 2:

Symfony Controller:

public function printReport(Request $request, $id) {
   // $bill = ....;
   $bill = $bill->loadById(['id' => $id]);
        
   return $this->render('reports/print.bill.html.twig', [
       'bill_id' => $bill //$bill results in 2 pages
   ]);
}

Twig Template:

{% extends "base.html.twig" %}

{% block body %}
        {% include 'pages/bills.front.html.twig' %}  
        {% include 'pages/bills.back.html.twig' %}   
{% endblock %}

jQuery:

let ids = []; // may contain up to 3000 ids which prints 2 pages each
$.each(ids, function (i, id) {
   // url to reload the iframe: 'print/bill/{id}'
   // reload the frame with each id and print the content of the frame
   // on load
});

My Option 1 results in a big file which times out or crashes the browser and my Option 2 will result in multiple iterations over the IDs in javascript/jquery while reloading an iframe.

Summary:

  1. How can I perform the second option with one print command?
  2. How can I print the first option with that large file with one print command?
  3. Any other suggestion as to how to do this would be highly appreciated.
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!