mpdf / mpdf

PHP library generating PDF files from UTF-8 encoded HTML
https://mpdf.github.io
GNU General Public License v2.0
4.37k stars 1.06k forks source link

Limit the PDF to three pages #1938

Closed riyash closed 11 months ago

riyash commented 11 months ago

Please describe the new functionality as best as you can.

Hello, I am using dynamic content to display in pdf. Everything is working fine but I just want to display 3 pages of PDF regardless of content. It is not necessary to fit the full content in 3 pages. Just need to display 3 pages in pdf and other content can be deleted or hidden.

$pdf = new \Mpdf\Mpdf();
$stylesheet = file_get_contents(get_stylesheet_directory_uri().'/style.css'); // external css

$pdf->SetHTMLHeader('<div class="pdf-header" style="margin-bottom:10px;background-color:#0095DB;text-align:center;"><img src="'.$image[0].'" style="width:18%;padding-top:10px;padding-bottom:20px;"></div>');
$pdf->AddPage('', // L - landscape, P - portrait 
        '', '', '', '',
        2, // margin_left
        2, // margin right
       30, // margin top
       10, // margin bottom
        2, // margin header
        2); // margin footer

$pdf->WriteHTML($stylesheet,1);
$pdf->WriteHTML($html,2); 

$pdf->TOC_Entry("content",0);

ob_end_clean();
$pdf->Output();

This is the code I am using right now. Please respond as soon as possible

riyash commented 11 months ago

@finwe How can you close this? without answering?

finwe commented 11 months ago

This is general troubleshooting and you already asked in Discussions where the question is still open.

riyash commented 11 months ago

@finwe But no one is responding there. so I posted here.