dart_pdf
dart_pdf copied to clipboard
This widget created more than 20 pages
Describe the bug Using a large table or wrap with thousands of lines inside MultiPage caused an Exception (This widget created more than 20 pages)
To Reproduce Code snippet to reproduce the behavior:
pdf.addPage(
MultiPage(build: (context) {
return [
Wrap(
children: List.generate(
2000,
(idx) => SizedBox(
width: double.infinity,
child:
Text('DATA $idx', style: TextStyle(fontSize: 20)))))
];
},
Is there a way to handle this ? I have a table with thousands of rows that can easily exceed 20 pages. What is the best way of doing this apart of splitting the Table into many small tables (Which may cause the header row to repeat in the middle of the page and may cause the rows to not be aligned as I use IntrinsicColumnWidth).
Yes, this exception is raised only with debug code (asserts enabled). And you can raise the limit with the maxPages property of MultiPage
Thanks for the quick answer, indeed I just saw the maxPages limit, increasing it worked. But now the PdfPreview took forever to display the 218 pages.
Yes, this PdfPreview is not optimized for a big number of pages.
Just checked the processing time : pdf.addPage( MultiPage( ... Took 44 seconds pdf.save() Took 29 seconds
I can understand why addPage is slow as I used IntrinsicColumnWidth calculation for the Table rows but I wonder why the save() method took this long too.
EDIT: Changing the IntrinsicColumnWidth to FlexColumnWidth reduced the time of pdf.save to 2.8 seconds. But MultiPage is still very slow.
pdf.addPage( MultiPage computes the layout multiple times to make sure everything fits in the pages. pdf.save() might layout a last time to get the pages number correctly and render the final result to the file.
Thanks for all the answers. I don't mind the time it takes as these are reports to generate once in many months, I'll just add a beautiful loading screen while it's processing and it won't matter a lot.
pdf.addPage( MultiPage computes the layout multiple times to make sure everything fits in the pages. pdf.save() might layout a last time to get the pages number correctly and render the final result to the file.
Could processing time be optimized if fixed column widths are defined?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Closing this stale issue because it has no activity.