User Tools

Site Tools


Sidebar

Multimedia

k23:k23.6:k23.6.1:k23.6.1.0:start

23.6.1.0 Class Printer

The class allows you to output documents directly to printers or to print and save the documents in a file (PDF or PostScript).

The class can be created. To create a new Printer object:

Dim hPrinter As Printer
hPrinter = New Printer() [ As "EventName" ]

23.6.1.0.1 Constants

The Printer class has these constants:

ConstantNumeric valueDescription
Custom0User-defined paper size. The paper size is defined via the PaperHeight and PaperWidth properties.
A31Paper size: 297 × 420 mm.
A42Paper size: 210 × 297 mm or 8.26 × 11.69 inches.
A53Paper size: 148 × 210 mm.
B54Paper size: 182 × 257 mm or 7.17 × 10.13 inches.
Executive6Paper size: 7.5 × 10 inches or 191 × 254 mm.
Legal7Paper size: 8.5 × 14 inches or 216 × 356 mm.
Letter5Paper size: 8.5 × 11 inches or 216 × 279 mm.
Horizontal1Both sides of a sheet of paper are used for printing. The paper is flipped over its horizontal edge.
Vertical2Both sides of a sheet of paper are used for printing. The paper is turned over its vertical edge.
Portrait0The height of the page is greater than its width (portrait format).
Landscape1The width of the page is greater than its height (landscape format).
Simplex0Only single-sided printing (simplex).

Table 23.6.1.0.1 : Constants of the Printer class (gb.qt4)

23.6.1.0.2 Properties

The Printer class has these properties:

PropertyData typeDescription
CopyCountIntegerReturns or sets the number of copies to be printed.
CollateCopiesBooleanReturns or specifies whether or not multiple copies should be collated into one document.
CountIntegerReturns or specifies the number of pages of the document to be printed. By default, the printed document consists of one page.
Duplex-Returns or sets the duplex printing mode. This property can have one of the following 3 values: Printer.Simplex: Only one-sided printing (simplex). Printer.Horizontal: Both sides of a sheet of paper are used for printing. The paper is rotated over its horizontal edge. Printer.Vertical: Both sides of each sheet of paper are used for printing. The paper is rotated over the vertical edge.
FirstPageIntegerReturns or specifies the first page to be printed. If this property is set to zero, the entire document is printed.
LastPageIntegerReturns or specifies the last page to be printed. If this property is set to zero, the document is printed up to the last page.
FullPageIntegerReturns or specifies whether the page should be drawn within the margins (FullPage is FALSE) or on the entire page (FullPage is TRUE). By default, this property is FALSE and (standard) margins are used.
GrayScaleBooleanReturns or specifies whether the print is in greyscale or full colour.
NameStringReturn or specify the printer name. The printer name identifies the printing device to which the document to be printed is sent.
NumCopiesIntegerReturn/set the number of copies to be printed.
OrientationIntegerReturns or defines the print orientation. This property can have one of the following values Printer.Portrait (0): The height of the page is greater than its width. This is the default value. Printer.Landscape (1): The width of the page is greater than its height.
OutputFileStringReturns or sets the path of the PDF or PostScript output file.
PageIntegerReturns the current page that needs to be printed.
Paper-Return or specification of the paper type for printing. This property can have one of the following values Printer.A4, Printer.A3, Printer.B5, Printer.Letter, Printer.Executive or Printer.Legal. Attention: This property returns Paper.Custom if the Printer.PaperWidth or Printer.PaperHeight properties have been defined!
PaperHeightIntegerReturns or sets the custom paper height in millimetres.
PaperWidthIntegerReturns or sets the custom paper width in millimetres.
ResolutionIntegerReturn or set the printer resolution in DPI (Dots Per Inches).
ReverseOrderBooleanReturn or specify whether the document pages should be printed in reverse order.

Table 23.6.1.0.2 : Properties of the Printer (gb.qt4) class

The Printer class (gb.qt4/5) also has these two static properties:

  • List: Returns the list of printers in the system.
  • Default: Returns the name of the default printer.

Example

  If Printer.List.Count = 0 Then
     sMessage = "<b><font size='+1', color='DarkRed'>"
     sMessage &= ("P R I N T - M O D U S")
     sMessage &= "</b></font><hr>"
     sMessage &= "->> " & ("No installed printer was detected.") & "<br>"
     sMessage &= "->> " & ("The program will be ended!")
     Message.Error(sMessage)
     Quit
  Else
     Print "Standard-Printer = "; Printer.Default
  Endif

This allows you to read out some of the default values or the defined properties of the printer:

  Print "DruckerName = "; hPrinter.Name
  Print "CollateCopies = "; hPrinter.CollateCopies
  Select Case hPrinter.Duplex
    Case 0
      Print "Duplex = 0: Single sided (simplex) printing only."
    Case 1
      Print "Duplex = 1: Both sides of each sheet of paper are used for printing. The paper is turned over its horizontal edge."
    Case Else
      Print "Duplex = 2: Both sides of each sheet of paper are used for printing. The paper is turned over its vertical edge."
  End Select
  Print "FullPage = "; hPrinter.FullPage
  Print "GrayScale = "; hPrinter.GrayScale
  Print "NumCopies = "; hPrinter.NumCopies
  If hPrinter.Orientation = 0 Then
     Print "Orientation = "; "Portrait"
  Else
     Print "Orientation = "; "Landscape"
  Endif
  If hPrinter.OutputFile <> Null Then
     Print "OutputFile = "; hPrinter.OutputFile
  Else
     Print "OutputFile = NULL (Printout on the installed printer)"
  Endif
  Print "Paper (2=DINA4)  = "; hPrinter.Paper
  Print "PaperHeight (mm) = "; hPrinter.PaperHeight
  Print "PaperWidth (mm)  = "; hPrinter.PaperWidth
  Print "Resolution (DPI) = "; hPrinter.Resolution
  Print "ReverseOrder     = "; hPrinter.ReverseOrder

This is the output in the console of the IDE:

DruckerName =  FS-1030D
CollateCopies =  True
Duplex = 1: Both sides of each sheet of paper are used for printing.
            The paper is turned over its horizontal edge.
FullPage  =  True
GrayScale =  True
NumCopies =  1
Orientation =  Portrait
OutputFile = NULL (Printout on the installed printer)
Paper (2=DINA4)  =  2
PaperHeight (mm) =  297
PaperWidth (mm)  =  210
Resolution (DPI) =  300
ReverseOrder     =  False

23.6.1.0.3 Methods

The Printer class has these methods:

MethodReturn typeDescription
Cancel()-Cancels the current print job.
Configure()BooleanOpens the printer configuration dialogue. This method returns TRUE if the user has cancelled the dialogue and FALSE otherwise.
PrintBooleanThe print process is started. A local event loop is executed during the process and the method returns when printing is complete. This method returns TRUE if the user has cancelled the print process or if an error has occurred. FALSE is returned if everything was OK.

Table 23.6.1.0.3 : Methods of the Printer class (gb.qt4)

23.6.1.0.4 Events

The Printer class has these events:

EventDescription
Begin()This event is triggered when the printing process begins.
End()This event is triggered when printing is complete.
Draw()This event is triggered for each (new) page that needs to be printed.
Paginate()This event is triggered so that you can paginate (add page numbers to) your document in the background. If you do not define an event handler, this event is not triggered. You must then define the Count property within the Begin() event handler. Otherwise - if you handle this event - the event handler will be called again and again until you explicitly define the Count property.

Table 23.6.1.0.4 : Events of the Printer class (gb.qt4/5)

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k23/k23.6/k23.6.1/k23.6.1.0/start.txt · Last modified: 09.03.2024 by emma

Page Tools