CopperSpice API  1.7.4
QPageSize Class Reference

Describes information about standard page sizes. More...

## Public Types

enum  PageSizeId

enum  SizeMatchPolicy

enum  Unit

## Public Methods

QPageSize ()

QPageSize (const QPageSize &other)

QPageSize (const QSize &size, const QString &name=QString (), SizeMatchPolicy matchPolicy=FuzzyMatch)

QPageSize (const QSizeF &size, Unit units, const QString &name=QString (), SizeMatchPolicy matchPolicy=FuzzyMatch)

QPageSize (PageSizeId sizeId)

~QPageSize ()

QSizeF definitionSize () const

Unit definitionUnits () const

PageSizeId id () const

bool isEquivalentTo (const QPageSize &other) const

bool isValid () const

QString key () const

QString name () const

QPageSize & operator= (const QPageSize &other)

QPageSize & operator= (QPageSize &&other)

QRectF rect (Unit units) const

QRect rectPixels (int resolution) const

QRect rectPoints () const

QSizeF size (Unit units) const

QSize sizePixels (int resolution) const

QSize sizePoints () const

void swap (QPageSize &other)

int windowsId () const

## Static Public Methods

static QSizeF definitionSize (PageSizeId pageSizeId)

static Unit definitionUnits (PageSizeId pageSizeId)

static PageSizeId id (const QSize &pointSize, SizeMatchPolicy matchPolicy=FuzzyMatch)

static PageSizeId id (const QSizeF &size, Unit units, SizeMatchPolicy matchPolicy=FuzzyMatch)

static PageSizeId id (int windowsId)

static QString key (PageSizeId pageSizeId)

static QString name (PageSizeId pageSizeId)

static QSizeF size (PageSizeId pageSizeId, Unit units)

static QSize sizePixels (PageSizeId pageSizeId, int resolution)

static QSize sizePoints (PageSizeId pageSizeId)

static int windowsId (PageSizeId pageSizeId)

## Friends

class QPlatformPrintDevice

## Detailed Description

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

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.

QPagedPaintDevice, QPdfWriter

## Member Enumeration Documentation

This enum type specifies what paper size QPrinter should use. QPrinter does not check that the paper size is available; it just uses this information, together with QPrinter::Orientation and QPrinter::setFullPage(), to determine the printable area.

The defined sizes (with setFullPage(true)) are:

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

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.

This enum describes how accurately a page size must match to adjusted to a standard page size

Constant Value Description
QPageSize::FuzzyMatch 0 Match to a standard page size if within the margin of tolerance
QPageSize::FuzzyOrientationMatch 1 Match to a standard page size if within the margin of tolerance regardless of orientation
QPageSize::ExactMatch 2 Only 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.

Constant Value Description
QPageSize::Millimeter 0
QPageSize::Point 1 1/72nd of an inch
QPageSize::Inch 2
QPageSize::Pica 3 1/72nd of a foot, 1/6th of an inch, 12 Points
QPageSize::Didot 4 1/72nd of a French inch, 0.375 mm
QPageSize::Cicero 5 1/6th of a French inch, 12 Didot, 4.5mm
QPrinter::DevicePixel 6

Note the difference between Point and DevicePixel. The Point unit is defined to be 1/72nd of an inch, while the DevicePixel unit is resolution dependent and is based on the actual pixels, or dots, on the printer.

## Constructor & Destructor Documentation

 QPageSize::QPageSize ( )

Creates a null QPageSize.

 QPageSize::QPageSize ( PageSizeId sizeId )
explicit

Creates a QPageSize of the standard sizeId. If pageSize is QPageSize::Custom then the resulting QPageSize will not be valid. Use the custom size constructor instead.

 QPageSize::QPageSize ( const QSize & size, const QString & name = QString(), SizeMatchPolicy matchPolicy = FuzzyMatch )
explicit

Creates a QPageSize of the given size in Points using the matching matchPolicy.

If the given pointSize matches a standard QPageSize::PageSizeId, then that page size will be used. Note that if the matchPolicy is FuzzyMatch this may result in the pointSize being adjusted to the standard size. To prevent this happening use a matchPolicy of ExactMatch instead.

If the given pointSize is not a standard QPageSize::PageSizeId then a QPageSize::Custom size will be created.

If name is null then the standard localized name will be used. If a custom page size then a custom name in the format "Custom (width x height)" will be created.

The matchPolicy defaults to FuzzyMatch.

 QPageSize::QPageSize ( const QSizeF & size, Unit units, const QString & name = QString(), SizeMatchPolicy matchPolicy = FuzzyMatch )
explicit

Creates a custom page of the given size in units.

If the given size matches a standard QPageSize::PageSizeId, then that page size will be used. If the matchPolicy is FuzzyMatch this may result in the size being adjusted to the standard size. To prevent this happening use a matchPolicy of ExactMatch instead.

If the given size is not a standard QPageSize::PageSizeId then a QPageSize::Custom size will be created. The original unit size will be preserved and used as the base for all other unit size calculations.

If name is null then a custom name will be created in the form "Custom (width x height)" where the size is expressed in units provided.

 QPageSize::QPageSize ( const QPageSize & other )

Copy constructs a new QPageSize from other.

 QPageSize::~QPageSize ( )

Destroys the page.

## Method Documentation

 QSizeF QPageSize::definitionSize ( ) const

Returns the definition size of the page size. If the QPageSize is invalid then the QSizeF will be invalid.

For a standard page size this will be the size as defined in the relevant standard, i.e. ISO A4 will be defined in millimeters while ANSI Letter will be defined in inches.

For a custom page size this will be the original size used to create the page size object.

definitionUnits()
 QSizeF QPageSize::definitionSize ( PageSizeId pageSizeId )
static

Returns the definition size of the standard pageSizeId. To obtain the definition units, call QPageSize::definitionUnits().

 Unit QPageSize::definitionUnits ( ) const

Returns the definition units of the page size. If the QPageSize is invalid then the QPageSize::Unit will be invalid.

For a standard page size this will be the units as defined in the relevant standard, i.e. ISO A4 will be defined in millimeters while ANSI Letter will be defined in inches.

For a custom page size this will be the original units used to create the page size object.

definitionSize()
 Unit QPageSize::definitionUnits ( PageSizeId pageSizeId )
static

Returns the definition units of the standard pageSizeId. To obtain the definition size, call QPageSize::definitionSize().

 PageSizeId QPageSize::id ( ) const

Returns the standard QPageSize::PageSizeId of the page, or QPageSize::Custom.

If the QPageSize is invalid then the ID will be the enum value QPageSize::Custom.

 PageSizeId QPageSize::id ( const QSize & pointSize, SizeMatchPolicy matchPolicy = FuzzyMatch )
static

Returns the standard QPageSize::PageSizeId of the given pointSize in points using the given matchPolicy.

If using FuzzyMatch then the point size of the PageSizeId returned may not exactly match the pointSize you passed in. You should call QPageSize::sizePoints() using the returned PageSizeId to find out the actual point size of the PageSizeId before using it in any calculations.

 PageSizeId QPageSize::id ( const QSizeF & size, Unit units, SizeMatchPolicy matchPolicy = FuzzyMatch )
static

Returns the standard QPageSize::PageSizeId of the given size in units using the given matchPolicy.

If using FuzzyMatch then the unit size of the PageSizeId returned may not exactly match the size you passed in. You should call QPageSize::size() using the returned PageSizeId to find out the actual unit size of the PageSizeId before using it in any calculations.

 PageSizeId QPageSize::id ( int windowsId )
static

Returns the PageSizeId for the given Windows DMPAPER enum value windowsId. If there is no matching PageSizeId then the enum value QPageSize::Custom is returned.

 bool QPageSize::isEquivalentTo ( const QPageSize & other ) const

Returns true if this page is equivalent to the other page. For example, if the page has the same size regardless of other attributes like name.

 bool QPageSize::isValid ( ) const

Returns true if this page size is valid. The page size may be invalid if created with an invalid PageSizeId, or a negative or invalid QSize or QSizeF, or the null constructor.

 QString QPageSize::key ( ) const

Returns the unique key of the page size. If the QPageSize is invalid then the key will be an empty string.

By default this is the PPD standard mediaOption keyword for the page size, or the PPD custom format key. If the QPageSize instance was obtained from a print device then this will be the key provided by the print device and may differ from the standard key.

This key should never be shown to end users, it is an internal key only. For a human-readable name use name().

name()
 QString QPageSize::key ( PageSizeId pageSizeId )
static

Returns the PPD mediaOption keyword of the standard pageSizeId. If the QPageSize is invalid then the key will be empty.

 QString QPageSize::name ( ) const

Returns a localized human-readable name for the page size. If the QPageSize is invalid then the name will be an empty string.

If the QPageSize instance was obtained from a print device then the name used is that provided by the print device. Note that a print device may not support the current default locale language.

 QString QPageSize::name ( PageSizeId pageSizeId )
static

Returns the localized name of the standard pageSizeId. If the QPageSize is invalid then the name will be empty.

 QPageSize & QPageSize::operator= ( const QPageSize & other )

Copy assigns from other and returns a reference to this object.

 QPageSize & QPageSize::operator= ( QPageSize && other )
inline

Move assigns from other and returns a reference to this object.

 QRectF QPageSize::rect ( Unit units ) const

Returns the page rectangle in the required units. If the QPageSize is invalid then the QRect will be invalid.

 QRect QPageSize::rectPixels ( int resolution ) const

Returns the page rectangle in Device Pixels at the given resolution. If the QPageSize is invalid then the QRect will be invalid.

 QRect QPageSize::rectPoints ( ) const

Returns the page rectangle in Postscript Points (1/72 of an inch). If the QPageSize is invalid then the QRect will be invalid.

 QSizeF QPageSize::size ( PageSizeId pageSizeId, Unit units )
static

Returns the size of the standard pageSizeId in the requested units.

 QSizeF QPageSize::size ( Unit units ) const

Returns the size of the page in the required units. If the QPageSize is invalid then the QSizeF will be invalid.

 QSize QPageSize::sizePixels ( int resolution ) const

Returns the size of the page in Device Pixels at the given resolution. If the QPageSize is invalid then the QSize will be invalid.

 QSize QPageSize::sizePixels ( PageSizeId pageSizeId, int resolution )
static

Returns the size of the standard pageSizeId in Device Pixels for the given resolution.

 QSize QPageSize::sizePoints ( ) const

Returns the size of the page in Postscript Points (1/72 of an inch). If the QPageSize is invalid then the QSize will be invalid.

 QSize QPageSize::sizePoints ( PageSizeId pageSizeId )
static

Returns the size of the standard pageSizeId in Points.

 void QPageSize::swap ( QPageSize & other )
inline

Swaps this QPageSize with other. This function is very fast and never fails.

 int QPageSize::windowsId ( ) const

Returns the Windows DMPAPER enum value for the page size. If the QPageSize is invalid then the Windows ID will be 0.

Not all valid PPD page sizes have a Windows equivalent, in which case 0 will be returned.