Help! My Report Generation Script Is Overlapping on Page Breaks After 3 Pages #151001
Replies: 2 comments
-
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
Your issue likely stems from mpdf not correctly handling automatic page breaks for large dynamic content. Try using $mpdf->SetAutoPageBreak(true, 15); before calling WriteHTML(), and ensure all large elements (like tables) have page-break-inside: avoid; in CSS. If issues persist, wrap each test entry in and experiment with mpdf->AddPage() where necessary.
|
Beta Was this translation helpful? Give feedback.
-
Body
Hey everyone,
I'm currently working on a report generation feature for a lab management system using PHP and generating PDFs with the
mpdf
library. Everything works fine, but when the report goes beyond two pages, I keep facing an issue where the text from the previous page overlaps the text on the next page, specifically after three pages. The overlap only occurs when we have a large amount of data on the report, such as when multiple tests are included in a single report. It’s causing the PDF to break formatting when there’s too much data.I tried using the page-break properties in my CSS and also applied some custom margin adjustments, but it doesn’t seem to solve the problem.
Here’s the relevant part of the code I'm using to generate the report:
`
Regards: https://www.concretesrichmondva.com/$html = '
<style> .page-break { page-break-before: always; } .content { font-size: 12px; line-height: 1.5; } .test-results { margin-top: 15px; } .test-header { background-color: #f0f0f0; padding: 8px; font-weight: bold; } .test-data { padding: 8px; } .footer { text-align: center; font-size: 10px; color: #555; } </style>Test Report
Patient: John Doe
Test Date: '. date("d-m-Y") .'
for ($i = 0; $i < 100; $i++) { // Simulating a lot of tests
$html .= '
';
}
$html .= '
$mpdf->WriteHTML($html);
$mpdf->Output();
?>``
Issue Details:
Overlapping Pages: When the report extends beyond three pages, the content from one page seems to bleed over to the next.
Test Data Overflow: The report might contain a lot of test data (as shown in the loop). With 100 test results, I run into an issue where the PDF is not breaking pages correctly after the second page, causing text and table rows to be cut off or overlap.
Things I've Tried:
page-break-before: always;
andpage-break-after: always;
in various spots.margin-bottom
to allow more room for content.mpdf->SetAutoPageBreak(true, 15);
method.What am I Missing? Is there something I'm overlooking in handling page breaks in a large report? Should I be adding more dynamic content-based logic to handle breaks better? Or is there an alternative way to manage dynamic page lengths?
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions