Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6878903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:46:51+00:00 2026-05-27T04:46:51+00:00

I am working my way through implementing a report generation solution using TCPDF. Some

  • 0

I am working my way through implementing a report generation solution using TCPDF. Some of my reports are small (2-3 pages), but the user has the option to select many reports at once, and request them all.

Currently I generate a single PDF containing all the reports, with each report starting on a new page, and using page grouping so the page numbering is restarted for each report. When it works, it work great, but after I select too many reports, the code churns away and I end up with an empty PDF.

UPDATE: I should have mentioned that creating a single PDF is a requirement from the client. They want to have a PDF table of contents to easily switch between reports within a single PDF when they have selected many reports.

My questions are:

  1. What is the most efficient way to produce this PDF without ending up with the blank PDF? I can’t seem to find if there is a limit on the size TCPDF can handle.

  2. Should I be using ob_start() in the PHP or is building up a big string as I am doing okay?

  3. My reports were originally HTML, so I am sending that TCPDF. However, would TCPDF’s performance be better if I used the other methods to output the info (e.g. Cell, MultiCell, etc.)?

Here is the piece of my code that outputs the PDF. The $pdf object is set up as per the relevant TCPDF examples included with the library:

foreach ($students_info as $student_info) {
    $info = $student_info->fetch_object();  // get query result object

    // put in the student information
    $pdf->set_student_info($info->lastName, $info->firstName, $info->rank, $info->idNum);

    $pdf->startPageGroup(); // start a page group to handle paging for multiple students
    $pdf->AddPage();        // add a page

    $html = "<style>";
    $html .= file_get_contents(/*some style sheet*/);
    $html .= file_get_contents(/*some other style sheet*/);
    $html .= "</style>";

    $html .= start_report_div($i);
    $html .= '<table class="report_table">'.                    
             '<tbody>'.
             '<tr><td>';
    $html .= display_report_title($report);
    $html .= display_student_info($db, $info);
    $html .= display_academic_comments_body($db, $info->studentID, $info->sessionID);
    $html .= display_signature_block($report);
    $html .= '</td></tr>'.
             '</tbody>'.                    
             '</table>';
    $html .= end_report_div();

    $pdf->writeHTML($html, // the content
            true,              // put a newline after text
            false,             // paint background, false = transparent
            true,              // reset last cell height
            false,             // add left padding
            ''                 // align
    );
    $html = '';       // reset for next student
    $pdf->lastPage(); // pointer to last page in case we are doing more than one student
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:46:51+00:00Added an answer on May 27, 2026 at 4:46 am

    Answer to question 1:

    Well, this is another one caused by my inexperience with PHP. The blank PDF was resulting from the default max_execution_time for PHP set to 30 sec. I used ini_set to set the value to 300 for the PDF generation script, and my report was generated in full.

    For a 16 page PDF, it took 1 min 30 sec to generate. Does that seem long to anyone with more TCPDF experience?

    Answer to question 3:

    I have done some experimenting, and using the direct PDF functions from TCPDF to generate the PDF is definitely faster than passing the HTML and CSS to TCPDF and then having it create the PDF. Makes sense, but still nice to see the actual performance difference. So although creating the layout for the PDF calls is tedious, if you have big PDFs, the performance gain is likely worth it.

    Questions 2:

    I would still appreciate input from more experienced PHP users as to the use of ob_start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working my way through some ASP.NET MVC reading and I have a web
I'm still working my way through some pretty basic Actionscript programming (in Flex), and
I'm working my way through some tutorials. I see the Zendcasts tutorials have me
I've looked through similar questions but not found the exact working solution I'm after.
I'm working my way through some simple programs for learning Erlang, and whenever I
While working my way through the Android tutorials, I came across something I don't
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC
I'm working my way through Agile Web Development with Rails and am running into
I've been working my way through Tim Heuer's Silverlight tuturial , in which you
I'm working my way through APress's Beginning Android 2 and I've made it all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.