[Gtk-sharp-list] Print on X = 2cm Y = 5.5cm ???
Victor Rafael Rivarola Soerensen (FANATICO y LOCO por Cristo)
vrrivaro at gmail.com
Mon Jan 9 22:08:37 EST 2006
This assuumes that your printer's resolution is 75 dots per inch. That
is really a wrong assumption to make, since "how to convert (x/y) to
cm depend on the Printer an Resolution".
The proper way is to change the 75.0 constant to an user defined
parameter. To get it, you should do a litttle work and write a three
step configuration section.
First, arrange for your program to print a rectangle of a measurement
you know, say 300x400 pixels or something similar.
Second, have the user measure up the rectangle with an old fashioned ruler.
Third, you should ask for those measurements back.
Finally, you should apply some algebra to thosee numbers to get the
amount of dots per pixels this particular device has. Use this number
in your method instead of the 75.0 constant.
If you don't care everything having to look the same size, forget everything.
I know that this is a lot of trouble, for both you and the user. Maybe
sometime in the future we will be able to interrogate the screens and
printers for this sort of info. Maybe, just maybe. In the meantime, it
is the only way you can be absolutely sure you will get everything to
Let me explain you why this is so. Lets say that you have a 15in
monitor at 800x600. If you knew that, for sure, you could figure it
out. But what if the 15in monitor was changed by a 21in (same
resoolution)? Same resolution, larger picture. The dot size just
increased dramatically. Remember most motitors have a set of
adjustment controls that let you fix up the size, horizontal and
verrtical scroll, etc? What do you think that these controls affect?
Printers have exactly the same problem for exactly the same reasons.
Jesus bless you,
Victor Rafael Rivarola Soerensen
2006/1/8, Wolfgang Mauer <W.Mauer at top-soft.info>:
> Hi all,
> i want to print some text with
> Gnome.Print.Moveto (Context, x, y);
> Gnome.Print.Show (Context, text);
> how to convert (x/y) to cm depend on the Printer an Resolution ?
> i found this
> public double ConvertToPixel (double cm)
> return cm * (75.0 / 2.54);
> is this the right way ?
> Gtk-sharp-list maillist - Gtk-sharp-list at lists.ximian.com
"Por cuanto eres tibio, y no frío ni caliente, te vomitaré de mi boca."
"Porque la Palabra de la Cruz es locura para los que se pierden; pero a
los que se salvan, esto es, a nosotros, es poder de Dios."
1 Corintios 1:18
More information about the Gtk-sharp-list