我有C#项目(ClassLibrary in ASP.NET MVC项目)
我想要打印一个图像(System.Drawing.Image)来使用PrintDocument文件
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照片查看器无法打开此图片,因为照片查看器不支持此文件格式,或者您没有照片查看器的最新更新。

发布于 2018-12-11 08:48:15
XPS文档编写器以*.xps或*.oxps格式打印。
您需要考虑将xps\oxps转换为.jpg
将文件的导出更改为xps
PrintFileName = @"D:\f.xps"https://stackoverflow.com/questions/53720227
复制相似问题