PMSetPageRange(_:_:_:)
Sets the valid range of pages that can be printed.
Declaration
func PMSetPageRange(_ printSettings: PMPrintSettings, _ minPage: UInt32, _ maxPage: UInt32) -> OSStatusParameters
- printSettings:
The print settings object whose page range you want to set.
- minPage:
The minimum page number allowed. This value appears as the default in the From field of the Print dialog.
- maxPage:
The maximum page number allowed. This value appears as the default in the To field of the Print dialog. Pass the constant
kPMPrintAllPagesto allow the user to print the entire document. If the first page is set to 1, then passingkPMPrintAllPagesas the maximum page number causes the All button to be selected.
Return Value
A result code. See Result Codes.
Discussion
The function PMSetPageRange allows applications to set the minimum and maximum page numbers that can be printed for a document. If the user enters a value outside of this range in the Print dialog, the value is set to the closest allowed value. You can use the PMGetFirstPage(_:_:) and PMGetLastPage(_:_:) functions to obtain the values entered by the user in the Print dialog.)
If you call the function PMSetPageRange to set the maximum page to a value other than the constant kPMPrintAllPages, the function PMSetPageRange causes the page range in the Print dialog to be properly restricted to the specified range. If you call the function PMSetPageRange without also calling the functions PMSetFirstPage or PMSetLastPage, then the Print dialog shows the specified page range in the From and To fields but with the All button selected. If you call the function PMSetPageRange and then call PMSetFirstPage or PMSetLastPage using the same page range you specified for PMSetPageRange, then the Print dialog shows the From button selected.
In all cases, if your application sets a range with PMSetPageRange and subsequently calls PMSetFirstPage(_:_:_:) or PMSetLastPage(_:_:_:) with values outside of the specified range, Core Printing returns a result code of kPMValueOutOfRange. Conversely, if your application calls PMSetPageRange after calling PMSetFirstPage or PMSetLastPage (or after displaying the Print dialog), the page range specified by PMSetPageRange takes precedence, and the first and last page values are adjusted accordingly.
If you call this function after initiating a print job, the change is ignored for the current job.
See Also
Accessing Data in Print Settings Objects
PMGetFirstPage(_:_:)PMSetFirstPage(_:_:_:)PMGetLastPage(_:_:)PMSetLastPage(_:_:_:)PMGetPageRange(_:_:_:)PMPrintSettingsGetJobName(_:_:)PMPrintSettingsSetJobName(_:_:)PMGetCopies(_:_:)PMSetCopies(_:_:_:)PMGetCollate(_:_:)PMSetCollate(_:_:)PMGetDuplex(_:_:)PMSetDuplex(_:_:)PMPrintSettingsGetValue(_:_:_:)PMPrintSettingsSetValue(_:_:_:_:)PMPrintSettingsCopyAsDictionary(_:_:)PMPrintSettingsCopyKeys(_:_:)