class KPrinter |
|
|
This class is the main interface to access the KDE print framework. It allows KDE applications to easily access the print system, through an interface that is compatible with QPrinter. So that the porting of an existing application should be as easy as replacing any occurrence of QPrinter by KPrinter. However applications that explicitly used the QPrintDialog class must be changed to the standard KPrinter way of accessing the print dialog. Basically, a KDE application will use the KPrinter object as a paint device, and will draw on it using QPainter. In a standard application, the use of the KPrinter class will look like this: #include The KPrinter interface also allows some more advanced possibilities, like the customization of the print dialog to integrate application specific print options. This is done by subclassing KPrintDialogPage and adding the page using addDialogPage(). When compiling an application that uses KPrinter, you must link to -lkdeprint, which when using the standard KDE build framework can be done by adding $(LIB_KDEPRINT) to _LDADD. The central interface class to access the KDE print system. Author Michael Goffioul See also QPrinter, KPrintDialogPage |
|
Constructor. This also restores/saves the state from a previous KPrinter object created within the same application run, if restore is true. Setting restore to false may be useful if you want an independent/clean KPrinter object. restore - if true, options will be restored/saved between successive KPrinter objects m - the mode to establish the KPrinter in (see QPrinter.PrinterMode) |
|
See QPrinter.abort(). |
|
See QPrinter.aborted() |
|
Adds a customized page to the print dialog. The pages will appear in a tab widget in the bottom half of the dialog, along with the standard "Copies" page. The page must be created and added each time you want open a print dialog with setup(). If you correctly reimplemented KPrintDialogPage.setOptions(), the settings will be restored from call to call, you don't have to worry about state saving/restoration. _page - the page to add See also KPrintDialogPage.setOptions() |
|
Adds a standard page to the print dialog. This is not useful yet as there's only one standard page defines CopiesPage. p - the page identifier See also StandardPageType |
|
Returns the application type concerning the print dialog. For internal use only. Returns the type for the current application See also setApplicationType() |
|
Configure the KPrinter object to be used with the printer named prname. After the call, the KPrinter object can be used without the need to call the print dialog. If prname is empty, then the KPrinter object is configured for the default printer. If prname corresponds to a pseudo-printer which needs an output file, a file dialog will be used. In that case, providing a parent widget for that dialog in parent may be useful. prname - the name of the printer for which the KPrinter object has to be configured parent - a parent widget, used a parent for a file dialog Returns boolean flag: if false, the KPrinter has not been correctly set up, and the application shouldn't use it to print. This may happen if the printer named prname has not been found or if the user clicked "Cancel" in the file dialog. See also setup() |
|
Returns the collate status of the current KPrinter. |
|
See QPrinter.colorMode(). |
|
See QPrinter.creator(). |
|
Returns the current page number. See also setCurrentPage() |
|
|
|
Get the default document directory, that is the directory used for any output file. By default, it is the $HOME directory. Returns the default output directory See also setDocDirectory |
|
Get the default document filename, that is the default basename used for the output file. Returns the default document basename See also setDocFileName() |
|
See QPrinter.docName(). |
|
wrapped method from QPrinter |
|
Returns the last error message issued by the print system. Unimplemented yet. Returns the last error message |
|
|
wrapped method from QPrinter |
|
Returns the first page to be printed. Deprecated Applications should use pageList() instead, which takes into account all options: collate, page order, ranges, page set, ... See also pageList() |
|
See QPrinter.fullPage(). |
|
For internal use only. |
|
|
For internal use only. Does a similar job as setOption(), except that all possible internal printers are initialized with the option if it has the form "kde-...". opts - the option set See also setOptions() |
|
|
See QPrinter.margins(). |
|
|
See QPrinter.maxPage(). |
|
|
See QPrinter.minPage(). |
|
See QPrinter.newPage(). |
|
See QPrinter.numCopies(). |
|
Starts the add printer wizard. This utility function allows any application for adding a printer using the KDEPrint powerful wizard.
parent - the parent widget for the wizard
Returns 1: success, 0: cancel, -1: error
The KPrinter object stores all its settings in an internal QMap structure on
QString. This allows to store any property. This method allows an application to access
any print option from the KPrinter object, using the option name. For example if your
application add a customized page to the print dialog, this page will saves its settings
into the KPrinter object using this QMap // add my custom page prt.addDialogPage( new MyDialogPage() ); // open print dialog if ( prt.setup( this ) ) { QString fntname = prt.option( "kde-myapp-fontname" ); ... do_something; ... } } key - the option name (key) Returns the option value correponding to the key, or QString() See also KPrintDialogPage, setOption, options(), setOptions() |
|
Returns the complete set of print options from the KPrinter object. For internal use. Returns the option set as a QMap object |
|
See QPrinter.orientation(). |
|
See QPrinter.outputFileName(). |
|
wrapped method from QPrinter |
|
See QPrinter.outputToFile(). |
|
Returns the page list to be printed, correpsonding to the options selected by the user. This takes into account collate, page order, page set, ranges, ... This is useful when the application does page selection itself. See also setCurrentPage() |
|
See QPrinter.pageOrder(). |
|
wrapped method from QPrinter |
|
Returns the page selection mode of the current application. Returns the page selection mode See also setPageSelection() |
|
Returns the page set of the current KPrinter object. |
|
See QPrinter.pageSize(). |
|
|
wrapped method from QPrinter |
|
wrapped method from QPrinter |
|
|
Returns the preview-only state for this KPrinter object. See also setPreviewOnly() |
|
Prints the files given in argument. This will first filter the files accorsing to the filtering options selected by the user in the print dialog, then send the filtered files to the printer with the print options selected. This function is called automatically when calling QPainter.end() for a painter object constructed on KPrinter. In normal use, you don't need this use this function explicitly. |
|
Returns the print program as set by setPrintProgram() or by the print dialog if a special printer has been selected. Returns the print command line See also setPrintProgram() |
|
See QPrinter.printerName(). |
|
See QPrinter.printerSelectionOption(). Unused. |
|
wrapped method from QPrinter |
|
DO NOT USE, WILL BE REMOVED. Obsolete |
|
Returns the page size in dot unit ( 1 dot = 1/72th in ). This method is intended for internal use, if you want to access actual page size, use a QPaintDeviceMetrics object instead. Note that the size returned by this method does not take resolution into account, and that it can returns invalid size if no page metric was found in the printer driver. DO NOT USE, WILL BE REMOVED. See also setRealPageSize Obsolete |
|
|
Removes a standard page from the print dialog. If your application doesn't want a standard page in the dialog, simply call this method with the correct identifier. By default, the print dialog includes the CopiesPage page. p - the page identifier See also StandardPageType |
|
Resturns the resolution of the current KPrinter object. The resolution is given in DPI. Returns resolution in DPI See also setResolution(), KPrinter() |
|
|
Returns the search name of the printer selected by the user. Each printer is identified by a unique name. This method is mainly used for state restoration. For internal use. Returns the unique printer search name See also setSearchName |
|
Sets the application type concerning the print dialog. You probably don't want to use it. For internal use only. type - the type for this application See also applicationType() |
|
Sets the collate status for the current KPrinter to type. |
|
See QPrinter.setColorMode(). |
|
See QPrinter.setCreator(). |
|
Sets the current page number. This page number will be used if the user selected "current page" in the print dialog. This option will only be enabled if the application does page selection itself and the application has called setCurrentPage() before opening the print dialog: MyClass.MyClass() { // declares my application able to do page selection KPrinter.setPageSelection( KPrinter.ApplicationSide ); } p - the current page number (starting from 1) |
|
Set the default document directory. This directory will be used as the default location for any output file. If not set, $HOME directory is used instead. dir - the new default output directory See also docDirectory() |
|
Set the default document filename. This filename will be used as the default basename for the output file, instead of the default "print". For example, by using setDocFileName("my_document"), the default output file will be $HOME/my_document.ps. filename - the default document basename to use See also docFileName() |
|
See QPrinter.setDocName(). |
|
wrapped method from QPrinter |
|
Sets the last error message. For internal use. msg - the error message |
|
wrapped method from QPrinter |
|
Sets the first and last page to be printed. See QPrinter.setFromTo(). |
|
See QPrinter.setFullPage(). |
|
Not used yet. |
|
|
See QPrinter.setMinMax(). |
|
See QPrinter.setNumCopies(). |
|
Adds or modifies an option in the KPrinter object. You probably don't need to use this function explicitly. This will be done implicitely for example when reimplementing KPrintDialogPage.getOptions(). key - the option name value - the option value See also option(), KPrintDialogPage |
|
|
Sets the option set in one operation. This method has some side effects like merging the internal map with the one given in argument, but only for option in the form "kde-...". For internal use only. opts - the option set to be merged in the KPrinter object |
|
See QPrinter.setOrientation(). |
|
See QPrinter.setOutputFileName(). |
|
wrapped method from QPrinter |
|
See QPrinter.setOutputToFile(). |
|
See QPrinter.setPageOrder(). |
|
Sets the page selection mode of the application. If needed, call this method somewhere at the beginning of your code. The default value is SystemSide. _mode - the mode for the application See also pageSelection() |
|
See QPrinter.setPageSize(). |
|
wrapped method from QPrinter |
|
Sets the KPrinter object to preview mode if on is true. In this mode, nothing will be printed but only a preview dialog will be popped up with the single "Close" action. Using this mode, any application can easily implement a preview action: void MyClass:doPreview() { // use a "clean" KPrinter object (independent from previous print jobs), // this is not necessary, it depends on the application KPrinter prt( false ); prt.setPreviewOnly( true ); on - the preview-only state See also previewOnly() |
|
Sets the command line to use when printing. This function is useful when using a KPrinter object without the print dialog, to control what to print and how to do it. The command line may contain the following tags: void createPNGOutputFile(const QString& filename) { // use a clean KPrinter object KPrinter prt(false); cmd - the print command line (containing at least the %in tag) See also printProgram() |
|
See QPrinter.setPrinterName(). |
|
See QPrinter.setPrinterSelectionOption(). Unused |
|
DO NOT USE, WILL BE REMOVED. Obsolete |
|
DO NOT USE, WILL BE REMOVED. Obsolete |
|
|
Set the resolution of the current KPrinter object. The resolution is given in DPI. This resolution mainly affects the accuracy for object positionning on the paint device, and does not influence the real resolution that will be used by the printer (this should be set in the driver settings). The resolution is usually defined in the constructor. dpi - the resolution in DPI See also KPrinter(), resolution() |
|
Sets the search name of the KPrinter object. For internal use. n - the unique printer search name See also searchName() |
|
Define the KPrinter object to use the actual printer resolution. Under some print systems (CUPS, Foomatic, PostScript printers), it is possible to know the actual resolution that is used by the printer, as selected by the user in the driver settings. If on is true, this KPrinter object will use the actual printer resolution if it is able to extract it. If nothing can be found, the default resolution will be the one defined by the PrinterMode argument used in the KPrinter constructor, or set explicitly by setResolution(). on - true if the KPrinter object should use the actual printer resolution See also resolution(), setResolution() |
|
Sets up the KPrinter object using the print dialog, returns true if the user clicked OK. parent - the parent widget to use for the print dialog caption - the caption to use in the print dialog forceExpand - force the expansion of the dialog (the show/hide button will be hidden) Returns boolean value corresponding to the button clicked by the user |
|
wrapped method from QPrinter |
|
Returns the last page to be printed. Deprecated Applications should use pageList() instead, which takes into account all options: collate, page order, ranges, page set, ... See also pageList() |
|
Dialog | - | ||
StandAlone | - | ||
StandAlonePersistent | - |
Collate | - | ||
Uncollate | - |
GrayScale | - | ||
Color | - |
Portrait | - | ||
Landscape | - |
FirstPageFirst | - | ||
LastPageFirst | - |
ApplicationSide | - | ||
SystemSide | - |
AllPages | - | ||
OddPages | - | ||
EvenPages | - |
A4 | - | ||
B5 | - | ||
Letter | - | ||
Legal | - | ||
Executive | - | ||
A0 | - | ||
A1 | - | ||
A2 | - | ||
A3 | - | ||
A5 | - | ||
A6 | - | ||
A7 | - | ||
A8 | - | ||
A9 | - | ||
B0 | - | ||
B1 | - | ||
B10 | - | ||
B2 | - | ||
B3 | - | ||
B4 | - | ||
B6 | - | ||
B7 | - | ||
B8 | - | ||
B9 | - | ||
C5E | - | ||
Comm10E | - | ||
DLE | - | ||
Folio | - | ||
Ledger | - | ||
Tabloid | - | ||
NPageSize | - | ||
CustomSize | - |
CopiesPage | - | ||
FilesPage | - | ||
CustomPage | - |