2

I am trying to print a pdf document using Gembox.Pdf in C# (.NET Framework 4.8). This is the code I use:

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
        });
      }
    }

It doesn't matter what I pass as jobName, when I look at the print queue I always see Xps Document. I am using the free version of Gembox.Pdf for now.

print queue

I already reached out to the Gembox.Pdf team and posted on the forum of Gembox but I have received no response so far.

Tijl .Reynhout
  • 901
  • 2
  • 9
  • 24

2 Answers2

3

This issue was resolved with this latest bugfix version:
https://www.gemboxsoftware.com/pdf/nightlybuilds/GBA15v1156.zip

Or this latest pre-released NuGet package:
Install-Package GemBox.Pdf -Version 15.0.1156-hotfix

Mario Z
  • 4,328
  • 2
  • 24
  • 38
  • I will try out this hotfix right now to see if it works. If it solves the problem we will be using Gembox for our clients. Will this hotfix also be included in the next release? – Tijl .Reynhout Jun 15 '21 at 11:18
  • Ok, it seems to be working now. Can I ask how it was possible to fix this so fast? Because you mentioned earlier that it would require quite a refactor of the code? – Tijl .Reynhout Jun 15 '21 at 11:38
  • 1
    @Tijl.Reynhout After investigating further, we noticed that `System.Printing.PrintQueue.CreateSerializationManager` method takes the `printJobName` from `System.Printing.PrintQueue.CurrentJobSettings.Description` property. It seems that the usage of this property results in consistent behavior. – Mario Z Jun 15 '21 at 13:06
  • And will this be added to the next release as well? :) because I want to avoid updating from te pre release hotfix version to the newest version (when it is released) and that this update will break it again if the hotfix is not included :) – Tijl .Reynhout Jun 15 '21 at 14:44
  • based on the previous question I asked, about it being included in the next release as well, we will make our decision to use Gembox.Pdf or a competitor. We will make this decision tomorrow, so could it be possible to answer this as soon as possible :) – Tijl .Reynhout Jun 15 '21 at 15:18
  • 1
    @Tijl.Reynhout of course, it will be included in the next release (which should be available by the end of this week). – Mario Z Jun 16 '21 at 02:39
  • thank you! We haver decided to use Gembox.Pdf for our company then :) – Tijl .Reynhout Jun 16 '21 at 06:29
1

I had a conversation with a support agent at Gembox.Pdf and it is not possible to set the DocumentName when printing to reflect this in the queue (even if the documentation says otherwise). The response of their support 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 was going to use this functionality to keep track of the status of my documents while printing but this is not possible according to them.

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.

So I won't be able to use Gembox.Pdf is the conclusion. Here is the full conversation.

Tijl .Reynhout
  • 901
  • 2
  • 9
  • 24