Changing the orientation of a PDF from portrait to landscape
If you are using the DataTables View layout, you export your visible entries to a PDF, however, this PDF is formatted in portrait mode.
If your View has lots of columns, this portrait mode can't quite accommodate all the information available, therefore we need to change its orientation to landscape.
Here's how:
/** * Modify the PDF button configuration for a specific view. * * @param array $button_config The current button configuration. * @param int $view_id The ID of the current view. * @return array Modified button configuration. */ add_filter('gravityview/datatables/button_pdf', function( $button_config, $view_id ) { if ( $view_id == 19 ) { $button_config['orientation'] = 'landscape'; } return $button_config; }, 10, 2);
Make sure to replace " 19" to your specific View ID, this way, only that View will have the PDF in portrait mode.
Learn where to add this code sample: Where do I add the code samples you share?