我使用包含QR码的图像打印XPS文档。 图像创建示例:
Image image = CreatePresentation(qrCode);
image.Height = 200;
image.Width = 200;
image.HorizontalAlignment = HorizontalAlignment.Center;
image.VerticalAlignment = VerticalAlignment.Center;
image.Stretch = Stretch.None;
其中
public static Image CreatePresentation(System.Drawing.Image source)
{
Stream stream = new MemoryStream();
source.Save(stream, ImageFormat.Png);
Image image = new Image();
BitmapImage src = new BitmapImage();
src.BeginInit();
src.StreamSource = stream;
src.EndInit();
image.Source = src;
return image;
}
当我有显示器dpi = 96时,打印页面上的图像尺寸(打印后在纸上)比我有montor dpi = 120时更大。 如何在不同的dpi上打印相同尺寸的图像?
答案 0 :(得分:0)
当我更换
image.Stretch = Stretch.None;
在
image.Stretch = Stretch.Fill;
图片开始打印正确