Re: Two newbie questions
- From: "Bob Powell [MVP]" <bob@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 24 Jun 2005 10:50:06 +0200
If you're printing then a real-world measurement system such as points,
millimeters or inches is best.
Remember that the printer bounds are declared in 100ths of an inch. NOT
pixels. You need to multiply the printer bounds by the DPI to get the real
pixel count if you want to use pixels at-all.
I haven't the faintest idea what sort of values you're producing with your
calculations on how the reciprocal width of a picturebox has a relation to
the left edge of a textbox. This is more esoteric than quantum physics. The
text doesn't show up because the result of that calculation puts it outside
the page margins obviously.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"zhaounknown" <zhaounknown@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7A138DA2-2217-4C11-8BDC-C1B879506E08@xxxxxxxxxxxxxxxx
> 1. PaintEventArgs.Graphics.Drawstring() need to specify the upper-left
> coordinate for the text to be drawn. What measure unit should be used for
> the
> coordinate?
>
> 2. Why the following piece of code can't print the Texts (on letter
> paper)?
> However, if remove the "e.Graphics.PageUnit=GraphicsUnit.Inch;" and set
> 0.5F/0.6F to be 0.5*100 and 0.6*100 can work.
>
> private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
> {
> Font newFont= new System.Drawing.Font("Arial", 10F,
> System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
> ((System.Byte)(134)));
>
> e.Graphics.PageUnit=GraphicsUnit.Inch;//
> float
> leftInch=(float)(this.textBox1.Left*1.0/this.pictureBox1.Image.Width*8.5);
> float
> topInch=(float)(this.textBox1.Top*1.0/this.pictureBox1.Image.Height*11.0);
>
> e.Graphics.DrawString(this.textBox1.Text, this.textBox1.Font,
> Brushes.Black,
> leftInch, topInch);
>
> e.Graphics.DrawString("X", newFont, Brushes.Black, 0.5F, 0.6F);
> }
.
- Follow-Ups:
- Re: Two newbie questions
- From: zhaounknown
- Re: Two newbie questions
- References:
- Two newbie questions
- From: zhaounknown
- Two newbie questions
- Prev by Date: Two newbie questions
- Next by Date: Re: Two newbie questions
- Previous by thread: Two newbie questions
- Next by thread: Re: Two newbie questions
- Index(es):
Relevant Pages
|
Loading