The PrintOperation class has a method called set_default_page_setup() which selects the default paper size, orientation and margins. To show a page setup dialog from your application, use the Gtk::run_page_setup_dialog() method, which returns a Gtk::PageSetup object with the chosen settings. Use this object to update a PrintOperation and to access the selected Gtk::PaperSize, Gtk::PageOrientation and printer-specific margins.
You should save the chosen Gtk::PageSetup so you can use it again if the page setup dialog is shown again.
// Within a class that inherits from Gtk::Window and keeps m_refPageSetup // and m_refSettings as members... auto new_page_setup = Gtk::run_page_setup_dialog(*this, m_refPageSetup, m_refSettings); m_refPageSetup = new_page_setup;
The Cairo coordinate system, in the draw_page handler, is automatically rotated to the current page orientation. It is normally within the printer margins, but you can change that via the PrintOperation::set_use_full_page() method. The default measurement unit is device pixels. To select other units, use the PrintOperation::set_unit() method.