在 C# 中使用 Gembox.Pdf 打印 pdf 时,打印队列中的 documentName 始终为 'XPS Document'

When printing a pdf with Gembox.Pdf in C# the documentName in the print queue is always 'XPS Document'

我正在尝试使用 C# (.NET Framework 4.8) 中的 Gembox.Pdf 打印 pdf 文档。这是我使用的代码:

public void PrintPdf(string fileToPrint, string printerName, string jobName)
    {
      ComponentInfo.SetLicense("FREE-LIMITED-KEY");
      using (var document = PdfDocument.Load(fileToPrint))
      {
        document.Print(printerName, new PrintOptions
        {
          DocumentName = jobName
        });
      }
    }

无论我将什么作为 jobName 传递,当我查看打印队列时,我总是看到 Xps 文档。我目前使用的是免费版Gembox.Pdf。

我已经联系了 Gembox.Pdf 团队并在 Gembox 论坛上发帖,但到目前为止我没有收到任何回复。

我在 Gembox.Pdf 与支持代理进行了交谈,打印时无法设置 DocumentName 以在队列中反映这一点(即使文档另有说明)。他们支持Agent的回复:

Unfortunately, this is currently not possible to achieve.

You see, in the past, I've tried doing it but found out that there is no stable solution for it in WPF.

The closest solution that I got was with "PrintSystemJobInfo.JobName" and "JobName.Commit", but it failed on more printers than it succeeded.

I'm afraid that in order to resolve these issues, we'll need to replace System.Printing with something else (like GDI+ implementation from System.Drawing.Printing or some other alternative).

We have an internal support ticket for this and I have added your report to it as well.

However, please note that this re-factoring requires quite a large time investment, which is why unfortunately, it won't be done any time soon.

我打算使用此功能在打印时跟踪我的文档的状态,但根据他们的说法,这是不可能的。

I see now, I'm afraid there is no way to do this.

The print method basically calls the XpsDocumentWriter.Write(DocumentPaginator) which doesn't provide any feedback.

So yes, you would need to check the jobs.

But unfortunately as mentioned before, the PrintSystemJobInfo.JobName doesn't work consistently which is why we don't have a solution for this.

所以我不会用Gembox.Pdf是结论。 Here 是完整的对话。

此问题已通过最新的错误修复版本得到解决:
https://www.gemboxsoftware.com/pdf/nightlybuilds/GBA15v1156.zip

或者这个最新预发布的 NuGet 包:
Install-Package GemBox.Pdf -Version 15.0.1156-hotfix