[英]Issue printing image as expected
我有一张要打印到法定尺寸的图像。 但是,这存在一些挑战。
这是我正在使用的代码:
PrintDocument pd = new PrintDocument();
pd.PrintPage += (sender, args) =>
{
Image i = Image.FromFile(Globals.TempDirectory + @"\temp.jpg");
Point p = new Point(100, 100);
Margins margins = new Margins(50, 50, 50, 50);
pd.DefaultPageSettings.Margins = margins;
args.Graphics.DrawImage(i, p);
};
pd.Print();
我一直在遇到麻烦,因为我无法设置边距并且似乎无法正确打印。 我希望它能合法打印,但是当我打印图像时,它没有正确旋转,只能打印到默认打印机。 我想尽一切办法使它起作用。
用C#打印很烂
尝试一个
printdialog()
允许用户选择打印机和设置。 一旦您能够使用它,其余的内容可能就会为您点击。
编辑:向您展示在哪里以及如何使用它。
PrintDialog pDialog = new PrintDialog();
if (pDialog.ShowDialog() == DialogResult.OK)
{
pd.PrinterSettings = pDialog.PrinterSettings;
pd.Print();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.