0

I am using php MPDF to generate a PDF files it working fine. But i want to set the height of a pdf page as auto based on content size. Content will come dynamically from DB. Anyone give some idea..

The following is my code

$p = 'P';
$mpdf->_setPageSize(array(200, round($mpdf->y)), $p);

this output also not correct

KMS
  • 566
  • 4
  • 16
  • Not sure if this may help? https://stackoverflow.com/questions/23663501/how-to-set-custom-page-size-in-mpdf – JustBaron Aug 30 '17 at 13:12
  • No, that is for exact size of PDF. But i want auto size based on Content size. – KMS Aug 30 '17 at 13:13
  • I think I understand. You want the page to be just tall enough to fit the content, and no taller. So if your content takes up 15cm of vertical space when rendered, you only want the page to be 16cm or something like that. Do I understand correctly? – Martin Joiner Aug 30 '17 at 13:27
  • Possible duplicate of https://stackoverflow.com/questions/33022101/mpdf-document-auto-height-pos-printer – Martin Joiner Aug 30 '17 at 13:29
  • 1
    Actually, I now think this answer is most helpful to you https://stackoverflow.com/questions/29395455/get-position-of-text-in-mpdf-to-determine-vertical-height-of-html-element – Martin Joiner Aug 30 '17 at 13:32
  • Thanks for your valuable response. I tried all of this, but i didn't get correct output. Output coming as either content will split into two page or blank space at bottom of the page. I want output like all content in a single page(if small amount of content or large content) without blank space at bottom. – KMS Aug 31 '17 at 05:41

0 Answers0