如何将图像居中放置在打印页面上? [英] How do you center an image to the print page?
本文介绍了如何将图像居中放置在打印页面上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将图像居中放置在打印页面上?谢谢您的回答.
How do you center an image to the print page? Thank you for your answer.
推荐答案
如果使用C#直接打印,则应该使用 ^ ]对象进行打印.
如果您查看PrintPage事件,它将包括可打印区域作为PrintPageEventArgs.MarginBounds,并且您具有图像的大小,因此将其居中只是将打印位置的左上角设置为Width的情况.
打印区域减去图像宽度,除以X为2;打印区域高度减去图像高度,除以2为Y.
将其输入Graphics.DrawImage方法中,它将居中.
If you are using C# to print directly, then you should be using a PrintDocument[^] object to do the print.
If you look at the PrintPage event, it includes the printable area as the PrintPageEventArgs.MarginBounds, and you have the size of your image, so centring it is just a case of setting the top left hand corner of the print position to the Width of the print area minus the Width of the image, divided by two for the X, and the Height of the print area minus the Height of the image, divided by two for the Y.
Feed that into the Graphics.DrawImage method, and it will be centred.
这篇关于如何将图像居中放置在打印页面上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文