Simple printing app

M

mitch

Hi, Could anyone help with the following.

I have a windows form. On it I have a function (DrawCross) to draw a
cross throught the centre of the form from corner to corner. The
function which draws the cross takes as input a graphics object, a
width and a height.

So on paint I call the function with the width and height set to the
forms client width and height. The upshot being that as I resize the
form so the cross is drawn through the centre of the form from the
corners. Resize the form big means a big cross, resize small means
small cross. Simple.

Now I want to print the cross. I implement the PrintDocument control in
the usual way. On the PrintDocuments' PrintPage event handler I call
the forms' DrawCross method and pass the PrintPageEventArgs' e.Graphics
object and the width and height of the form.

Now it all works fine. I get the print preview image. But as you will
see, the image size is the SAME as the form size. So if the form is
sized small, the print preview will consist of a white page with the
cross at the top left. If the form is sized big, the preview will be of
part of the cross - it won't fit on the page.

How can I get the cross to fill the page exactly. I thought it would be
as easy as passing
pgSettings.Bounds.Width and pgSettings.Bounds.Height as the width and
height to DrawCross. But it doesn't quite work. If I do this, the cross
is of exactly the right size but the print preview window is cropping
the image of the cross in a way related to the size of the form.

Basically what form shows, I want to fill paper with. Can I do it?

Thanks for any help.
Mitch.
 

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