[Gambas-user] About Printer

Fabien Bodard gambas.fr at ...626...
Tue Jul 19 14:53:17 CEST 2011


Benoit,

Paint.scale work good if there is not text ..; but if there is ...
then text font size is increased by the scale too


the only way i've found is in the joined archive


Le 19 juillet 2011 14:43, Benoît Minisini
<gambas at ...1...> a écrit :
>> i want to print a rectangle on a page.
>>
>> i have this code:
>>
>> ----------------
>> ' Gambas class file
>>
>> Private Const PAPER_FACTOR As Float = 7.55
>>
>> Public Sub btnPrint_Click()
>>
>>   If prtPrinter.Configure() Then Return
>>
>>   Me.Enabled = False
>>   Inc Application.Busy
>>   prtPrinter.Print
>>   Dec Application.Busy
>>   Me.Enabled = True
>>
>> End
>>
>> Public Sub prtPrinter_Draw()
>>
>>   Dim X As Float
>>   Dim Y As Float
>>   Dim W As Float
>>   Dim H As Float
>>   Dim wFactor As Float
>>   Dim hFactor As Float
>>
>>   txtArea.Text &= "Begin Draw\n"
>>
>>   'Set scale
>>   wFactor = prtPrinter.PaperWidth / Paint.Width
>>   hFactor = prtPrinter.PaperHeight / Paint.Height
>>   Paint.Scale(wFactor, hFactor)
>>
>>   'Set Color to red
>>   Paint.Color(Color.RGB(255, 0, 0, 0))
>>
>>   'Set X,Y margin to 0,0
>>   X = 0
>>   Y = 0
>>
>>   'W points * 7.55 = W mm
>>   'W = 100 = 100 mm = 10 cm
>>   W = 200 * PAPER_FACTOR
>>   H = 100 * PAPER_FACTOR
>>
>>   'Draw a rectangle
>>   Paint.Rectangle(X, Y, W, H)
>>
>>   'Write it on paper
>>   Paint.Stroke
>>
>> End
>>
>> ------------------
>>
>> At the beginning i make a scale
>> Paint.Scale(wFactor, hFactor)
>>
>> according to page
>> http://gambasdoc.org/help/howto/print?v3
>>
>> to have absolute coordinates.
>>
>> Problem #1
>> -----------
>> i want the rectangle to be printed at (x,y) = (0,0)
>> so i set
>>
>>   'Set X,Y margin to 0,0
>>   X = 0
>>   Y = 0
>>
>> But at the page it is printed 46 points inside and lower.
>> If i use
>>   X = -46
>>   Y = -46
>>
>> i get the rectangle at the beginning of page, straight to border.
>
> You must set the FullPage to print on the entire page. Otherwise margins will
> be taken into account.
>
>>
>> Problem #2
>> -----------
>> i want to set width to 100 millimeters. I found that i have to multiply
>> the number in millimeters with 7.55 so i use this as constant
>> PAPER_FACTOR
>>
>> How really does this work? why this number?
>
> You shouldn't. Can you print the values of prtPrinter.PaperWidth,
> prtPrinter.PaperHeight, Paint.Width, Paint.Height, wFactor, hFactor...?
>
>>
>> Problem #3
>> -----------
>>   'Set Color to red
>>   Paint.Color(Color.RGB(255, 0, 0, 0))
>>
>> color does not work on printing i get black lines
>
> Paint.Color creates a brush that you must assign to the Paint.Brush property:
>
>        Paint.Brush = Paint.Color(Color.RGB(255, 0, 0, 0))
>
> Regards,
>
> --
> Benoît Minisini
>
> ------------------------------------------------------------------------------
> Magic Quadrant for Content-Aware Data Loss Prevention
> Research study explores the data loss prevention market. Includes in-depth
> analysis on the changes within the DLP market, and the criteria used to
> evaluate the strengths and weaknesses of these DLP solutions.
> http://www.accelacomm.com/jaw/sfnl/114/51385063/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fabien Bodard
-------------- next part --------------
A non-text attachment was scrubbed...
Name: anotherprintingdemo-0.0.1.tar.gz
Type: application/x-gzip
Size: 9810 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20110719/ed8e61d1/attachment.bin>


More information about the User mailing list