2

I am using mpdf library to generate pdf from html(table) content in php. I am using below code

<?php 
    session_start();
    $html=$_POST['html'];
    include 'mpdf.php';
    $mpdf=new mPDF(); 
    $mpdf->WriteHTML($html);
    $mpdf->Output();
    exit;
    ?>

When the size of html table is small, say about 100 rows, then PDF is generated properly. But when size of table is more, say about 1000-2000 rows, then pdf is not generated.

Is there any size constraint in mpdf? What can be done to solve this problem? Or is there any other better library to generate pdf's in php

I have tried increasing memory allocated to 256,512 and 1024 mb in php.ini by using this code ini_set('memory_limit', '256M'); I also tried increasing time limit, it is now generating PDF but taking more time to generate and PC becomes slow. How can I release memory?

4
  • 2
    Have you tried setting a time limit? Commented Apr 30, 2014 at 13:39
  • Actually am not getting any time out error.Still do i need to set time limit? Commented Apr 30, 2014 at 13:41
  • Try and add a higher time-limit and see what happens. Commented Apr 30, 2014 at 13:51
  • It works on increasing time limit. It is taking so much time to generate PDF and making whole system slow. Is there any way that I can release the memory once pdf is generated Commented Apr 30, 2014 at 17:53

1 Answer 1

3

Try

ini_set('max_execution_time', 0);
ini_set("memory_limit", "2G");

$mpdf->packTableData = true;

And as usual, be wary of bad nesting, unclosed tags, improper escaping, or wrong colspan settings. Check generated HTML code with http://validator.w3.org/

Sign up to request clarification or add additional context in comments.

1 Comment

It is taking so much time to generate PDF and making whole system slow. Is there any way that I can release the memory once pdf is generated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.