class Printing.PageSetup

An instance of the PageSetup class is used to hold the information specified by the Page Setup command, such as margins, paper size and orientation.

The Application object maintains a default PageSetup instance in its page_setup property, and provides a default implementation of the Page Setup command which edits it. When a view prints itself in response to the Print command, if it can't obtain a PageSetup object from its associated model, it uses the one from the Application.

There is no provision for saving the Application's PageSetup object; its settings are retained only as long as the application runs. If you want page setup information saved with your document, you should attach a PageSetup object of your own to it and save it along with your document's data (see below).

You can explicitly invoke a Page Setup dialog for a specific PageSetup object using the present_page_setup_dialog() function.

Saving page setup information

PageSetup objects are pickleable, to facilitate saving and restoring them. This method is recommended, rather than saving its properties individually, because pickled PageSetup objects retain platform-dependent information that may not be exposed through the generic properties. If you pickle a PageSetup object and later restore it on the same platform, all of the platform-specific information will be preserved.

The generic properties are also saved in a platform-independent way, so that if you unpickle it on a different platform, the most important attributes ought to come across as best they can.

There are also from_string() and to_string() methods which take and return a pickled representation as a string. You may find these more convenient if you are using a non-pickle-based file format.


Creates a PageSetup object with default settings.


A string describing the paper size, such as "A4" or "Letter".

A tuple (width, height) giving the size of the paper in points.

One of 'portrait' or 'landscape'.

The name of the printer for which the page setup has been created.

Distances from the edge of the paper to the printed area.

A tuple containing the four margin values.
The size of the printed area.  This is equal to the paper size minus the margins.
A rectangle representing the printed area. The origin of the coordinate system is at the top left corner of the page.

Class Methods

Creates a PageSetup object from a string returned by the to_string() method.


Returns a string-encoded representation suitable for passing to from_string().

Related Functions

Presents a Page Setup dialog box for the specifed PageSetup object and allows the user to edit it. If the user accepts the changes, true is returned. Otherwise, the PageSetup object is unaltered and false is returned.