我正在使用Amyuni PDF Creator .Net使用Windows服务打印PDF.
Windows服务在“本地系统”用户帐户下运行.当我尝试使用上述库进行打印时,它以错误的字体打印PDF.请参阅附件(Wrong font in PDF printing).
仅某些打印机(例如Brother MFC-8890DW打印机)仍然存在此问题.
但是对于具有上述Windows服务的同一台打印机,如果未选中上述打印机属性中的启用高级打印功能设置,它将正确打印PDF.请参阅附件(Disable Advanced printing features).
using (FileStream file1 = new FileStream(pdfFile, FileMode.Open, FileAccess.Read))
{
using (IacDocument doc1 = new IacDocument())
{
doc1.Open(file1, string.Empty);
doc1.Copies = 1;
bool printed = doc1.Print(printer, false);
}
}
但是,相同的Windows服务可以为其他某些打印机(例如HP LaserJet P1005)正确打印PDF,或者启用已选中或未选中的高级打印功能.
解决方法:
如果无法访问您使用的同一台打印机,则很难确切知道发生了什么.我的最佳猜测是,当选中“启用高级打印功能”时,该打印机的驱动程序在处理进程级字体(使用GDI功能AddFontResourceEx注册的字体)时会遇到问题.这就是Amyuni PDF Creator使用嵌入在PDF文件中的字体的方式,对于您所呈现的文件就是这种情况.
可能的解决方法是使用attribute “PrintAsImage” of the Document class.
代码如下所示:
//set license key This is needed only with licensed version
acPDFCreatorLib.SetLicenseKey("your company", "your activation code");
//Create a new document instance
Amyuni.PDFCreator.IacDocument doc = new Amyuni.PDFCreator.IacDocument(null);
doc.AttributeByName("PrintAsImage").Value =1;
//Open the file here (...)
//Print to default printer
pdfCreator1.Document.Print("", false);
另一种选择是使用Amyuni PDF Creator将文件另存为xps,然后将xps文件发送到打印机:
// Create print server and print queue.
LocalPrintServer localPrintServer = new LocalPrintServer();
PrintQueue defaultPrintQueue = LocalPrintServer.GetDefaultPrintQueue();
defaultPrintQueue.AddJob("my document", "c:\\temp\\mytempfile.xps", true);
免责声明:我为Amyuni Technologies工作.
标签:pdf,printing,c,net 来源: https://codeday.me/bug/20191119/2033654.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。