【发布时间】:2018-12-11 08:37:30
【问题描述】:
我有 C# 项目(ASP.NET MVC 项目中的 ClassLibrary)
我想使用 PrintDocument 将图像 (System.Drawing.Image) 打印到文件中
private static void SendToPrinter(Image barkod)
{
PrintDocument pd = new PrintDocument();
pd.PrinterSettings = new PrinterSettings
{
PrinterName = "Microsoft XPS Document Writer",
PrintToFile = true,
PrintFileName = @"D:\f.jpg"
};
pd.PrintPage += (o, e) =>
{
Point loc = new Point(100, 100);
e.Graphics.DrawImage(barkod, loc);
};
pd.Print();
barkod.Dispose();
}
发生的情况是文件是在特定位置创建的,但是当我尝试打开图像时出现错误
Windows 照片查看器无法打开此图片,因为照片查看器不支持此文件格式,或者您没有照片查看器的最新更新。
【问题讨论】:
标签: c# printdocument