class printerCanvas

superclass(es) canvas
subclass(es) -
description The printerCanvas class is a specialized class derived from the canvas class, it extends the canvas class with methods for scaling the output.
see also printerSetupDialog - printJobDialog - printer

tasks

Printing on a document is almost the same as painting on a canvas, all the methods for drawing on a canvas can be used for printing. However the main difference between painting on a canvas and printing is the number of pixels per inch and the size of a paper. For instance, a 600 DPI (dots per inch) printer and an A4 paper (210 x  297 mm = 8.26 x 11, 69 inch) means that an A4 paper has 4956 x 7014 pixels, so a paper has much more pixels than a screen (for instance, 1280 x 1024 pixels). Another difference is that most printers have an unprintable area, this is an area where the printer cannot print any characters because it is to close to the edge of a paper.
If a string is painted with a 600 DPI printer then the letters are so small that they are unreadable, that is why the printerCanvas class has methods to scale the output. By scaling the output is made larger or smaller.

To adapt the printer output to the output on a screen there is the method adaptScaleScreen/2. The scale in the X and Y direction can also be set by the methods adaptScaleX/3 and adaptScaleY/3. for instance,

adaptScaleX(4800, 1200, true).  %Make all the character 4 times larger (4800 / 1200 = 4)

The canvas class has two methods for determining the number of pixels of a device, horDeviceSize/1 and verDeviceSize/1. To make all the output larger by 2 the following piece of code can be used.

horDeviceSize(Output),
Out2 is Output // 2,
adaptScaleX(Output, Out2, true).  %Make all the character 2 times larger (4800 / 2400 = 2)

The printerCanvas has more methods to query the size of the scaled axis, horScaleSize/1 and verScaleSize/1, the current scale factors, horScaleFactor/1 and verScaleFactor/1, the number of pixels per inch, pixelsPerInchX/1 and pixelsPerInchY/1 and if a printer can print bitmap images, canPrintImage/1.

methods

adaptScaleToScreen(Factor, Output)

func Adapt the printer output so that the printed characters resemble the output on the screen. The factor determines the amount of scaling, a factor larger than 1.0 makes the output smaller and if the factor is smaller than 1.0 the printed result is enlarged.
pre The variable Factor must contain a floating point number.
post If the scaling factor was successfully changed then true was assigned to Output, else false was assigned.

screenScale(Output)

func Return the screen scale factor currently used, the factor value of adaptScaleToScreen/2 was returned.
pre TRUE
post The scaling factor was assigned to Output.

adaptScaleX(Source, Dest, Output)

func Adapt the scaling factor in the X direction, the number of source pixels is scaled to become the specified number of destination pixels. ( if Source / Dest > 1 then the output is enlarged, else it is made smaller)
pre The variables Source and Dest must both contain integer values.
post If the scaling factor was changed then Output was assigned true, else it was assigned false.

adaptScaleY(Source, Dest, Output)

func Adapt the scaling factor in the Y direction, the number of source pixels is scaled to become the specified number of destination pixels. ( if Source / Dest > 1 then the output is enlarged, else it is made smaller)
pre The variables Source and Dest must both contain integer values.
post If the scaling factor was changed then Output was assigned true, else it was assigned false.

horScaleSize(Output)

func Return the scaled size of the paper in the X direction.
pre TRUE
post The number of pixels of the scaled axis in the X direction was assigned to the variable Output.

putHorSize(Size)

func Set the number of pixels in the X direction for the scaled axis.
pre The variable Size must contain an integer value.
post The number of pixels of the scaled X axis was changed to the value of the variable Size.

verScaleSize(Output)

func Return the scaled size of the paper in the Y direction.
pre TRUE
post The number of pixels of the scaled axis in the Y direction was assigned to the variable Output.

putVerSize(Size)

func Set the number of pixels in the Y direction for the scaled axis.
pre The variable Size must contain an integer value.
post The number of pixels of the scaled Y axis was changed to the value of the variable Size.

horScaleFactor(Output)

func Determine the current horizontal scaling factor,  (Source pixels / Dest pixels). If the value of 1.0 is returned no scaling is done. A value larger than 1.0 means that the output is enlarged.
pre TRUE
post The floating point value representing the current scaling factor was assigned to the variable Output.

verScaleFactor(Output)

func Determine the current vertical scaling factor,  (Source pixels / Dest pixels). If the value of 1.0 is returned no scaling is done. A value larger than 1.0 means that the output is enlarged.
pre TRUE
post The floating point value representing the current scaling factor was assigned to the variable Output.

pixelsPerInchX(Output)

func Determine the current number of pixels per inch in the X direction.
pre TRUE
post The number of pixels in the X direction was assigned to the variable Output.

pixelsPerInchY(Output)

func Determine the current number of pixels per inch in the Y direction.
pre TRUE
post The number of pixels in the Y direction was assigned to the variable Output.

canPrintImage(Output)

func Determine if the current printer can print bitmap images.
pre TRUE
post If the printer can print bitmap images then was true assigned to Output, else was false assigned.