Change the orientation of the PDF document to landscape using exportToPdfDocument
Hi,
I am trying to make a document landscape using exportToPdfDocument but I cannot do it.
In the documentation there is an example ( https://help.syncfusion.com/flutter/datagrid/export-to-pdf#change-the-orientation-of-the-pdf-document ) using the exportToPdfGrid() function, but in my case I need to use exportToPdfDocument(). Is it possible? Could you provide a simple example?
Thanks in advance.
The example using exportToPdfGrid is the following:
PdfDocument document = PdfDocument();
document.pageSettings.orientation = PdfPageOrientation.landscape;
PdfPage pdfPage = document.pages.add();
PdfGrid pdfGrid = key.currentState!.exportToPdfGrid();
pdfGrid.draw(
page: pdfPage,
bounds: Rect.fromLTWH(0, 0, 0, 0));
final List<int> bytes = document.saveSync();
Thank you so much for your kind and encouraging words. We truly appreciate your support and are delighted to know that the information we've shared has been helpful to you and your retro games website.
Your appreciation means a great deal to us. Please don’t hesitate to reach out if you need any further assistance or insights—we’re always here to help in any way we can.
Yes, it is possible to set the orientation when using exportToPdfDocument(), even though the example in the documentation uses exportToPdfGrid(). You can achieve
unblocked games
this by creating a PdfDocument and specifying the PdfPageSettings with orientation: PdfPageOrientation.landscape before adding your content. Then, when you export, the resulting PDF will be in landscape mode. Essentially, the process involves creating a new PdfDocument, setting its page orientation, drawing your content (tables, text, or other elements), and finally saving or exporting the document. This approach gives you full control over the page layout while still using exportToPdfDocument().
Thank you for your input! At present, orientation customization is supported via the exportToPdfGrid method. The exportToPdfDocument method does not directly offer this capability. While setting document.pageSettings.orientation = PdfPageOrientation.landscape might appear to be a solution, exportToPdfDocument() internally creates its own pages, and this setting may not apply unless page creation and drawing are handled manually—similar to the approach demonstrated in the User Guide example.
- 5 Replies
- 5 Participants
-
EÑ Eñaut
- Jun 16, 2025 01:15 PM UTC
- Aug 29, 2025 07:50 AM UTC