c# - System.Runtime.InteropServices.ExternalException:“GDI+ 中发生一般错误。” 在通过 C# 打印文件时
问题描述
我为喀拉拉邦的一座寺庙制作了一个计费软件,用于为向寺庙供品的奉献者打印 rcpt。单击打印按钮时,打印机必须将 rcpt 详细信息打印到表单中。我制作了一个打印按钮和一个打印文档,并将文档编码如下:
private void RCPT_PRINTABLE_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(RCPTNO.Text, new Font("ML-NILA02_NewLipi", 15, FontStyle.Bold), Brushes.Black, new Point(94 , 109));
e.Graphics.DrawString(RcptDate.Text, new Font("ML-NILA02_NewLipi", 15, FontStyle.Regular), Brushes.Black, new Point(408, 109));
e.Graphics.DrawString(NameRcpt.Text, new Font("Times New Roman", 13, FontStyle.Regular), Brushes.Black, new Point(94, 132));
e.Graphics.DrawString(RCPTSTAR.Text, new Font("ML-NILA02_NewLipi", 15, FontStyle.Regular), Brushes.Black, new Point(408, 132));
//DATEBOOKING PRINT BEGIN
if (Vazhipaad1.Text != "--")
{
e.Graphics.DrawString("1. "+Vazhipaad1.Text + "(" + dateTimePicker2.Text + ")"+ "(" + No1.Text + "*" + Rate1.Text + ")", new Font("ML-NILA02_NewLipi", 15, FontStyle.Regular), Brushes.Black, new Point(57, 200) );
e.Graphics.DrawString("₹" + textBox1.Text, new Font("ML-NILA02_NewLipi", 15, FontStyle.Regular), Brushes.Black, new Point(434, 200));
}
if (Vazhipaad2.Text != "--")
{
e.Graphics.DrawString("2. "+Vazhipaad2.Text + "(" + dateTimePicker1.Text + ")" + "(" + No2.Text + "*" + Rate2.Text + ")", new Font("ML-NILA02_NewLipi", 15, FontStyle.Regular), Brushes.Black, new Point(57, 234));
e.Graphics.DrawString("₹" + textBox2.Text, new Font("ML-NILA02_NewLipi", 15, FontStyle.Regular), Brushes.Black, new Point(434, 234));
}
if (Vazhipaad3.Text != "--")
{
e.Graphics.DrawString("3. "+Vazhipaad3.Text + "(" + dateTimePicker5.Text + ")" + "(" + No3.Text + "*" + Rate3.Text + ")", new Font("ML-NILA02_NewLipi", 15, FontStyle.Regular), Brushes.Black, new Point(57, 265));
e.Graphics.DrawString("₹" + textBox3.Text, new Font("ML-NILA02_NewLipi", 15, FontStyle.Regular), Brushes.Black, new Point(434, 265));
}
e.Graphics.DrawString("₹" + TOTAL.Text, new Font("ML-NILA02_NewLipi", 20, FontStyle.Regular), Brushes.Black, new Point(397, 302));
e.Graphics.Dispose();
}
但是当执行此代码时,在第二个 if 语句中,第一行出现异常 System.Runtime.InteropServices.ExternalException: 'A generic error occurred in GDI+.' 被系统抛出。我参考了很多网站,但没有找到完美的答案。请帮我!!!!!!!!!!!!!!!
解决方案
推荐阅读
- flutter - 在我的颤振应用程序中,黑屏在启动屏幕之前来来去去
- r - 如何生成和编写 .Rmd 报告的个性化版本?
- docker - 如何使 Mercure hub 的 API 平台自动发现机制与 Docker 映像一起使用?
- python-3.x - 通过 xpath 查找元素时遇到问题(python 中的 selenium 模块)
- java - Sun 是否致力于 JDK 的两种不同实现(JDK 和 OpenJDK),为什么?
- c - 我没有包括
头文件,为什么我还能成功调用getpid()函数? - java - 使用 GSON 定义反序列化类型
- javascript - 如何在更新之前清空状态中的数组?
- azure - 使用 ARM 模板部署 NSG 流日志时自动启用网络观察程序资源
- excel - 如何使用表格最后一行中的两个值使用 Excel vba 将行添加到另一个表格