PDF is not generating more than 2 pages in dompdf

62 Views Asked by At

I'm encountering an issue within my PHP application when using the Dompdf library (version 2.0.4) to generate PDFs. Despite including product items and customer information, only the first two pages of the PDF are displayed, and content exceeding two pages isn't shown properly.

My application is built using PHP and incorporates the Dompdf library for PDF generation. Despite trying various options, I can't seem to resolve this limitation, even after attempting to adjust configuration settings.

Any insights or suggestions on troubleshooting and resolving this issue specifically within the PHP environment would be greatly appreciated.

require_once 'path/autoload.php';
use Dompdf\Dompdf;
use Dompdf\Options;
$options = new Options();
$options->set('isRemoteEnabled', true);
$dompdf = new Dompdf($options);
ob_start();
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
</head>

<body>
    <div id="container">
        <p>This is a sample PDF generated using Dompdf.</p>
        <div> More content here </div>
    </div>
</body>

</html>
$html = ob_get_clean();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$pdf_content   = $dompdf->output();
$file_to_save = AFRFQ_PLUGIN_DIR . 'includes/pdf/pdf-files/Quotes.pdf';
file_put_contents($file_to_save, $pdf_content);
$to = $admin_email;
$subject     = 'Your PDF';
$message     = 'Here is the PDF you requested.';
$headers     = array('Content-Type: text/html; charset=UTF-8');
$attachments = array(AFRFQ_PLUGIN_DIR . 'includes/pdf/pdf-files/Quotes.pdf');
wp_mail($to, $subject, $message, $headers, $attachments);
0

There are 0 best solutions below