You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I want to print image file at the center of paper exactly.
How to do this? I am confused with the world, page and device coordinate manipulation. Please give me the simplest example in C# to accomplish my goal.
After struggling in a couple of days, I find the best solution for it without having to call P/Invoke (to obtain hard margin) as other people did. PageSettings exposes HardMargin to ease our life.
Since e.MarginBounds is measured relative from upper left corner of printable area (rather than the edge of actual page), we must move e.MarginBounds using HardMargin point as an offset.
Note that: both MarginBounds and HardMargin are measured in hundredths of an inch.