• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

PrintForm function

When I use this function, it is not centered on the paper.

Is there a way to center it?

1 Solution
Here is a method using Win32 API to capture a form and handle the output as you wish:

I'm not sure how you can print the whole window otherwise.
There is a PrintForm component from Microsoft.

Now if you just want to print the client area of the form, there may be another way.
The idea would be to take a snapshot of the screen in those coords and then print it.
DotNet has very controlled printing so if you can get the screen shot to a bitmap, you can get the page width and height and figure out where to print the image to center it.


X=(PageWidth/2)-(BMPScreenShot.Width/2) to center horizontally.
The only kicker is that you have to be in the same coordinate system...pixels, points or whatever. Also the margin may affect it depending upon whether the printer is set to use absolute 0,0 are 0,0 or the top left of the inside of top and left margins as 0,0.

Hope this helps.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now