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();



5 Replies

AP Abinesh Palanisamy Syncfusion Team June 17, 2025 02:22 PM UTC

Hi Eñaut ,
 
Based on the provided details, it seems you are trying to use the exportToPdfDocument method to change the orientation
In SfDataGrid, the page orientation can currently be customized when using the exportToPdfGrid method by setting the PdfDocument.pageSettings.orientation property.
Could you please let us know why you specifically need to change the orientation through exportToPdfDocument? If there are any particular use cases or requirements on your end, sharing those would greatly help us evaluate this request and consider it for future enhancements.
Regards,
Abinesh P


LU luicy July 3, 2025 04:34 AM UTC

I am the administrator of the retro games website, and I am extremely grateful to you for the wealth of valuable and beneficial information you have shared. I will provide you with unwavering support, so please continue.




GR Gowtham Ravi Syncfusion Team July 3, 2025 01:17 PM UTC

Hi Luicy,

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.


Regards,
Gowtham R


NI Nielsen Isaac August 28, 2025 08:03 AM UTC

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().



GR Gowtham Ravi Syncfusion Team August 29, 2025 07:50 AM UTC

Hi Nielsen,

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.
If you’ve found a workaround or implemented a custom solution that enables orientation control with exportToPdfDocument, we’d greatly appreciate it if you could share the details so others may benefit as well.


Regards,
Gowtham R

Loader.
Up arrow icon