Another Printing Question

A

Anne DeBlois

Hi,

I am currently testing the printing features of Visual Studio 2005 (VB.NET)
We want to release a database application that prints label pages. The
labels must contain a picture box.

I found this code to print an image:

e.Graphics.DrawImage(Image.FromFile("c:\\dev\\Projects\\Impression\\merci.png"),
20, 750)

With this code, the picture will print with its original dimensions. Is it
possible to change this line with a picturebox or any control that allows us
to resize the image (and keep its proportions) within a limited space?

Thanks in advance!

ANNE DEBLOIS
 
H

Herfried K. Wagner [MVP]

Anne DeBlois said:
I am currently testing the printing features of Visual Studio 2005
(VB.NET) We want to release a database application that prints label
pages. The labels must contain a picture box.

I found this code to print an image:

e.Graphics.DrawImage(Image.FromFile("c:\\dev\\Projects\\Impression\\merci.png"),
20, 750)

With this code, the picture will print with its original dimensions. Is it
possible to change this line with a picturebox or any control that allows
us to resize the image (and keep its proportions) within a limited space?

You can basically pass the scaled height and width to 'DrawImage'. Note
that backslashes inside string literals must not be escaped in VB.NET.
 
A

Anne DeBlois

Herfried K. Wagner said:
You can basically pass the scaled height and width to 'DrawImage'. Note
that backslashes inside string literals must not be escaped in VB.NET.

You mean I can pass parameters to the DrawImage method?

As for the escaped backslashes, I had to do it because I got a first chance
exception (FileNotFound) using "simple" backslashes when compiling...
Someone suggested that I escape them.

Thanks!

A.D.
 
H

Herfried K. Wagner [MVP]

Anne DeBlois said:
You mean I can pass parameters to the DrawImage method?

Yes, just check out the different overloads in the documentation or the
object browser.
As for the escaped backslashes, I had to do it because I got a first
chance exception (FileNotFound) using "simple" backslashes when
compiling... Someone suggested that I escape them.

Sorry, but that's nonsense for VB.NET -- are you sure you are using VB.NET?!
 
A

Anne DeBlois

Herfried K. Wagner said:
Yes, just check out the different overloads in the documentation or the
object browser.

Thank you very much!
Sorry, but that's nonsense for VB.NET -- are you sure you are using
VB.NET?!

Of course, I am using VB.NET in VS2005. And yeah, that's a nonsense but it
got me rid of that filenotfound exception at that time.

Anne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top