Printing - how to set printer properties

<< Click to Display Table of Contents >>

Navigation:  Programming > Printing and PDF Export >

Printing - how to set printer properties

WPTools Version 9 provides you with the possibility to easily change important printer options (such as paper tray) using an easy to use property PrintParameter.

During the printing the "PrintParameter" are evaluated and applied to the DEVMODE structure which is used by the printer driver.  There is also the event OnSetupPrinterEvent to let you change the DEVMODE structure yourself. This feature can be disabled using the flag wpDoNotChangePrinterDefaults in property PrintParameter.PrintOptions.

 

The demo 'PrinterSetup' shows how to:

change the orientation of a certain page

activate duplex mode (requires support of the printer!)

display the available paper trays

change the paper tray for the first and the rest of the pages

print the document

use BeginPrint/EndPrint to print the contents of two different editors into one printer cue - with a continuous page numbering.

 

clip0083

 

You can use the TWPRichText method Print to print the complete document or PrintPages to print a range of documents. If you first call BeginPrint(title, pagenumber) a new printing cue is opened. For best results it is necessary to provide this function with the number of the first page. This number is 0 based. (This is necessary since the printer properties for the first page must be set before Printer.BeginDoc is executed)

 

If you print from different editors please make sure that the text in all this editors is formatted. If an editor is not visible call ReformatAll! To get the correct page numbering assign the total page count to WPRichText.Enviroment.CombinedPrintPageCount. You will also need to set the flag wpUsePrintPageNumber in the property PrintParameter.PrintOption of the editor which started the printing cue. The value of this -first- property will automatically be used by all the editors which are printing into the same printing cue.

When printing is finished don't forget to call EndPrint!

 

Notes:

If you loaded or or created test and it was not displayed on screen before you need to call ReformatAll before you can print it.

The property Printer.PageNumber is not updated as usual.

We recommend to add a possibility (i.e. INI entry) to your application to make it possible for the end user to set wpDoNotChangePrinterDefaults.

WPTools Version 9 selects the paper from the list of the available papers of this printer. Only if the paper is not found (by comparing the size) 'custom' is used. The list of papers is updated at printime, property PageDefs is not used. So it is possible to change the printer (using Printer.PrinterIndex) at any time!

Please also see the chapter about WYSIWYG

You will need to temporarily hide mail-merge markers using the propertry InsertPointTextAttr.Hidden if this flag is not true anyways.

To quickly read the current page size from the default printer use the method ReadPrinterProperties.