[Gambas-user] Printing with Gambas and the IDE

Benoît Minisini g4mba5 at gmail.com
Tue Jul 9 20:20:20 CEST 2019


Hi people,

To add printing feature to the IDE code and text editor, I created a new 
component named 'gb.form.print' that provides a generic preview and 
printing dialog, and some features to make drawing the page contents a 
bit easier.

1) Instead of calling MyPrinter.Print(), you call MyPrinter.Preview().

2) You have to implement the Begin, End, Paginate and Print events the 
same way as before.

3) The Paint device is automatically scaled and translated so that width 
and height are in 1/10th of millimeters, and represent the printing zone 
without the margins.

For example, a, A4 portrait page with 1 cm margin at each border will 
create a paint device whose width is 1900 and height 2770.

4) Thanks to the new Paint.FontScale property, using a 10 point size 
font will always draw a 10 point size font wherever we are drawing: to 
the screen, a PDF file, or a printer.

Beware: at the moment it works only if you *assign* the font to the 
Paint.Font property, because this is the only moment the Paint.FontScale 
is applied.

For example :

hFont = Font["Monospace,10"]
Print hFont.Size ' ==> 10
Paint.FontScale = 2
Paint.Font.Size = hFont
Print Paint.Font.Size ' ==> 20

This is really a trick at the moment. I had to do that because font size 
is supposed to be absolute, but this is really the case only if you use 
the font on a screen. Otherwise this can be false. Thanks Microsoft for 
that mess.

5) The GTK components have been fixed so that printing works and behave 
the same as with QT components.

6) The preview dialog is a fork of the 'gb.report2' preview dialog made 
by Fabien Bodard. It is based on his DocumentView control that I fixed a 
bit by the way.

7) It's not tested a lot. I even didn't test it on a real printer yet!

Please report any problem and ask questions if needed, as usual.

Regards,

-- 
Benoît Minisini
-------------- next part --------------
A non-text attachment was scrubbed...
Name: capture_20190709_195939.png
Type: image/png
Size: 151771 bytes
Desc: not available
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190709/e1b636b1/attachment-0001.png>


More information about the User mailing list