[Lazarus] Printer printable width&height
Michael Van Canneyt
michael at freepascal.org
Sat Jul 28 15:05:31 CEST 2018
The selectprinter demo prints a kind of test page.
However, on linux the rectangle it draws on the page seems to be off. The
left margin seems to be about right, but the bottom and top margins fall off
If I try to code something myself, I would code it like this:
procedure TMainForm.GetPageRect(Out PageRect : TRect);
Function ToPixels(aUnit,ares : Integer) : Integer;
if PSDemo.Units in [pmDefault,pmMillimeters] then
// 1/1000 of a mm
Result:=Round(((aUnit div 1000) / 25.4) * Ares)
Result:=aUnit * Ares
LM,RM,TM,BM,H,W : Integer;
PSDemo is a TPageSetupDialog. The values displayed by the lazarus test
program match more or less what my code gets.
Similarly, if I draw a rectangle with the rectangle defined as above,
the bottom-right falls off the page.
So the question is: what is the origin of the printer canvas ?
Top-left corner of the paper (What it should be IMO ?)
Or is it the Top-left corner of the printable area of the page ?
How to obtain the origin of the printable area ?
Is the PageWidth/Pageheight relative to this origin ?
Or is there something else wrong in the printer class or the demo code ?
(using GTK2, 64-bit)
More information about the Lazarus