c# - AmyuniPDF 以错误的字体(特殊字符)打印 PDF 文档

标签 c# .net pdf printing

我正在使用 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 工作。

关于c# - AmyuniPDF 以错误的字体(特殊字符)打印 PDF 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35035708/

相关文章:

c# - 如何将属性直接传递给 OpenGL 中的片段着色器?

.net - 有没有办法让 App.config 文件引用另一个完整的配置文件? (。网)

c# - WPF DataGrid(在 .NET 4.0 中,不是 Toolkit),使用 ICollectionView 进行 header 排序

macos - 如何在不增加尺寸的情况下修剪 eps 或 pdf

php - 如何使用 php 旋转 pdf 文档?

c# - 我怎样才能在 C# 中创建一个类似 monoid 的界面?

c# - 压缩目录并上传到 FTP 服务器,而无需在 C# 中本地保存 .zip 文件

c# - UserControl 的基类属于哪一层?

c# - 使用Selenium WebDriver查找列表元素

r - 带有 3 个点的矩阵不会在 Rmarkdown 中呈现为 pdf