QPageSize Class

The QPageSize class describes the size and name of a defined page size. More...

Header: #include <QPageSize>
qmake: QT += gui
Since: Qt 5.3

This class was introduced in Qt 5.3.

Public Types

enum PageSizeId { A0, A1, A2, A3, A4, …, LastPageSize }
enum SizeMatchPolicy { FuzzyMatch, FuzzyOrientationMatch, ExactMatch }
enum Unit { Millimeter, Point, Inch, Pica, Didot, Cicero }

Detailed Description

This class implements support for the set of standard page sizes as defined in the Adobe Postscript PPD Standard v4.3. It defines the standard set of page sizes in points, millimeters and inches and ensures these sizes are consistently used. Other size units can be used but will be calculated results and so may not always be consistent. The defined point sizes are always a integer, all other sizes can be fractions of a unit.

The defined size is always in width x height order with no implied page orientation. Note that it is possible for page sizes to be defined where the width is greater than the height, such as QPageSize::Ledger, so you cannot rely on comparing the width and height values to determine page orientation.

For example, A4 is defined by the standard as 210mm x 297mm, 8.27in x 11.69in, or 595pt x 842pt.

You can also define custom page sizes with custom names in any units you want and this unit size will be preserved and used as the base for all other unit size calculations.

When creating a QPageSize using a custom QSize you can choose if you want QPageSize to try match the size to a standard page size. By default QPaperSize uses a FuzzyMatch mode where it will match a given page size to a standard page size if it falls within 3 postscript points of a defined standard size. You can override this to request only an exact match but this is not recommended as conversions between units can easily lose 3 points and result in incorrect page sizes.

A QPageSize instance may also be obtained by querying the supported page sizes for a print device. In this case the localized name returned is that defined by the printer itself. Note that the print device may not support the current default locale language.

The class also provides convenience methods for converting page size IDs to and from various unit sizes.

See also QPagedPaintDevice and QPdfWriter.

Member Type Documentation

enum QPageSize::PageSizeId

This enum type lists the available page sizes as defined in the Postscript PPD standard. These values are duplicated in QPagedPaintDevice and QPrinter.

The defined sizes are:

ConstantValueDescription
QPageSize::A05841 x 1189 mm
QPageSize::A16594 x 841 mm
QPageSize::A27420 x 594 mm
QPageSize::A38297 x 420 mm
QPageSize::A40210 x 297 mm, 8.26 x 11.69 inches
QPageSize::A59148 x 210 mm
QPageSize::A610105 x 148 mm
QPageSize::A71174 x 105 mm
QPageSize::A81252 x 74 mm
QPageSize::A91337 x 52 mm
QPageSize::B0141000 x 1414 mm
QPageSize::B115707 x 1000 mm
QPageSize::B217500 x 707 mm
QPageSize::B318353 x 500 mm
QPageSize::B419250 x 353 mm
QPageSize::B51176 x 250 mm, 6.93 x 9.84 inches
QPageSize::B620125 x 176 mm
QPageSize::B72188 x 125 mm
QPageSize::B82262 x 88 mm
QPageSize::B92344 x 62 mm
QPageSize::B101631 x 44 mm
QPageSize::C5E24163 x 229 mm
QPageSize::Comm10E25105 x 241 mm, U.S. Common 10 Envelope
QPageSize::DLE26110 x 220 mm
QPageSize::Executive47.5 x 10 inches, 190.5 x 254 mm
QPageSize::Folio27210 x 330 mm
QPageSize::Ledger28431.8 x 279.4 mm
QPageSize::Legal38.5 x 14 inches, 215.9 x 355.6 mm
QPageSize::Letter28.5 x 11 inches, 215.9 x 279.4 mm
QPageSize::Tabloid29279.4 x 431.8 mm
QPageSize::Custom30Unknown, or a user defined size.
QPageSize::A1031 
QPageSize::A3Extra32 
QPageSize::A4Extra33 
QPageSize::A4Plus34 
QPageSize::A4Small35 
QPageSize::A5Extra36 
QPageSize::B5Extra37 
QPageSize::JisB038 
QPageSize::JisB139 
QPageSize::JisB240 
QPageSize::JisB341 
QPageSize::JisB442 
QPageSize::JisB543 
QPageSize::JisB644,
QPageSize::JisB745 
QPageSize::JisB846 
QPageSize::JisB947 
QPageSize::JisB1048 
QPageSize::AnsiALetter= Letter
QPageSize::AnsiBLedger= Ledger
QPageSize::AnsiC49 
QPageSize::AnsiD50 
QPageSize::AnsiE51 
QPageSize::LegalExtra52 
QPageSize::LetterExtra53 
QPageSize::LetterPlus54 
QPageSize::LetterSmall55 
QPageSize::TabloidExtra56 
QPageSize::ArchA57 
QPageSize::ArchB58 
QPageSize::ArchC59 
QPageSize::ArchD60 
QPageSize::ArchE61 
QPageSize::Imperial7x962 
QPageSize::Imperial8x1063 
QPageSize::Imperial9x1164 
QPageSize::Imperial9x1265 
QPageSize::Imperial10x1166 
QPageSize::Imperial10x1367 
QPageSize::Imperial10x1468 
QPageSize::Imperial12x1169 
QPageSize::Imperial15x1170 
QPageSize::ExecutiveStandard71 
QPageSize::Note72 
QPageSize::Quarto73 
QPageSize::Statement74 
QPageSize::SuperA75 
QPageSize::SuperB76 
QPageSize::Postcard77 
QPageSize::DoublePostcard78 
QPageSize::Prc16K79 
QPageSize::Prc32K80 
QPageSize::Prc32KBig81 
QPageSize::FanFoldUS82 
QPageSize::FanFoldGerman83 
QPageSize::FanFoldGermanLegal84 
QPageSize::EnvelopeB485 
QPageSize::EnvelopeB586 
QPageSize::EnvelopeB687 
QPageSize::EnvelopeC088 
QPageSize::EnvelopeC189 
QPageSize::EnvelopeC290 
QPageSize::EnvelopeC391 
QPageSize::EnvelopeC492 
QPageSize::EnvelopeC5C5E= C5E
QPageSize::EnvelopeC693 
QPageSize::EnvelopeC6594 
QPageSize::EnvelopeC795 
QPageSize::EnvelopeDLDLE= DLE
QPageSize::Envelope996 
QPageSize::Envelope10Comm10E= Comm10E
QPageSize::Envelope1197 
QPageSize::Envelope1298 
QPageSize::Envelope1499 
QPageSize::EnvelopeMonarch100 
QPageSize::EnvelopePersonal101 
QPageSize::EnvelopeChou3102 
QPageSize::EnvelopeChou4103 
QPageSize::EnvelopeInvite104 
QPageSize::EnvelopeItalian105 
QPageSize::EnvelopeKaku2106 
QPageSize::EnvelopeKaku3107 
QPageSize::EnvelopePrc1108 
QPageSize::EnvelopePrc2109 
QPageSize::EnvelopePrc3110 
QPageSize::EnvelopePrc4111 
QPageSize::EnvelopePrc5112 
QPageSize::EnvelopePrc6113 
QPageSize::EnvelopePrc7114 
QPageSize::EnvelopePrc8115 
QPageSize::EnvelopePrc9116 
QPageSize::EnvelopePrc10117 
QPageSize::EnvelopeYou4118 
QPageSize::LastPageSizeEnvelopeYou4= EnvelopeYou4

Due to historic reasons QPageSize::Executive is not the same as the standard Postscript and Windows Executive size, use QPageSize::ExecutiveStandard instead.

The Postscript standard size QPageSize::Folio is different to the Windows DMPAPER_FOLIO size, use the Postscript standard size QPageSize::FanFoldGermanLegal if needed.

enum QPageSize::SizeMatchPolicy

ConstantValueDescription
QPageSize::FuzzyMatch0Match to a standard page size if within the margin of tolerance.
QPageSize::FuzzyOrientationMatch1Match to a standard page size if within the margin of tolerance regardless of orientation.
QPageSize::ExactMatch2Only match to a standard page size if the sizes match exactly.

enum QPageSize::Unit

This enum type is used to specify the measurement unit for page sizes.

ConstantValueDescription
QPageSize::Millimeter0 
QPageSize::Point11/72th of an inch
QPageSize::Inch2 
QPageSize::Pica31/72th of a foot, 1/6th of an inch, 12 Points
QPageSize::Didot41/72th of a French inch, 0.375 mm
QPageSize::Cicero51/6th of a French inch, 12 Didot, 4.5mm