Apose.Pdf.Printing: PaperSourceKind.Custom cannot specify RawKind

Greetings,

I’m a junior developer of small business and I’d like to get some help with Aspose.PDF in .NET.
The issue I’m facing is I’m trying to print several documents from several trays but the configuration for selecting a tray is within PaperSourceKind and it doesn’t satisfy the conditions.

In the previous versions of Aspose.PDF for .Net, assigning just the SourceName (like “Tray 1”) would have been sufficient in order to find the tray. But since the version 23.10, it was not enough to assign the SourceName but I needed the PaperSourceKind as well.
(Thanks to this post, I was able to get a bit forward: https://forum.aspose.com/t/breaking-change-in-version-23-10-pagesettings-printersettings-papersources-not-existing/278399)

No problem, I was able to assign the following:

case "Tray 1":
    return new Aspose.Pdf.Printing.PaperSource { Kind = Aspose.Pdf.Printing.PaperSourceKind.Upper, SourceName = "Tray 1" };
case "Tray 2":
    return new Aspose.Pdf.Printing.PaperSource { Kind = Aspose.Pdf.Printing.PaperSourceKind.Middle, SourceName = "Tray 2"};
case "Tray 3":
    return new Aspose.Pdf.Printing.PaperSource { Kind = Aspose.Pdf.Printing.PaperSourceKind.Lower, SourceName = "Tray 3" };

And it works!

The problem is when I’d like to assign to another tray like Tray 4 onwards, the only PaperSourceKind I’m able to use is PaperSourceKind.Custom
And it doesn’t print on that selected Tray (tray 4), so I tried the following:

case "Tray 4":
    var nativeSettings = new System.Drawing.Printing.PrinterSettings();
    nativeSettings.PrinterName = @$"\\{printLog.PrinterSettings.PrintServer}\{printLog.PrinterSettings.PrinterName}";
    var paperSources = nativeSettings.PaperSources;
    var paperSource = paperSources.Cast<System.Drawing.Printing.PaperSource>().SingleOrDefault(ps => ps.RawKind == 256);
    return new Aspose.Pdf.Printing.PaperSource { Kind = (Aspose.Pdf.Printing.PaperSourceKind)paperSource.Kind, SourceName = paperSource.SourceName };

And still it doesn’t print on the Tray 4

Kind regards,

Elias El Harrak Samadi

EDIT #1: I was able to get the exact RawKind for Tray 4 which is 256 but even like that, it didn’t work.
EDIT #2: I’m going to add the screenshot of the papersource.
image.png (30.8 KB)

@elias.elharraksamadi

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-56997

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi Asad Ali,

Any update on that matter? Thanks.

Kind regards,

Elias

@elias.elharraksamadi

We are afraid that the earlier logged ticket has not been yet resolved. It will be prioritized on a first come first serve basis and as soon as it is fully investigated, we will share updates with you regarding its resolution or ETA. Please spare us some time.

We apologize for the inconvenience.

@elias.elharraksamadi

Beginning with the release 24.8, the RawKind public property will be added to the Aspose.Pdf.Printing.PaperSource class, so that you will be able to set the correct RawKind for the custom paper source.

You should be able to set the required paper source using the following code snippet:

case "Tray 4":
    var nativeSettings = new System.Drawing.Printing.PrinterSettings();
    nativeSettings.PrinterName = @$"\\{printLog.PrinterSettings.PrintServer}\{printLog.PrinterSettings.PrinterName}";
    var paperSources = nativeSettings.PaperSources;
    var paperSource = paperSources.Cast<System.Drawing.Printing.PaperSource>().SingleOrDefault(ps => ps.RawKind == 256);
    return new Aspose.Pdf.Printing.PaperSource { RawKind = paperSource.RawKind, SourceName = paperSource.SourceName };

Or using the ToAsposePaperSource() extension method (that in the 24.8 release will be made to honor the original PaperSource’s RawKind as well):

case "Tray 4":
    var nativeSettings = new System.Drawing.Printing.PrinterSettings();
    nativeSettings.PrinterName = @$"\\{printLog.PrinterSettings.PrintServer}\{printLog.PrinterSettings.PrinterName}";
    var paperSources = nativeSettings.PaperSources;
    var paperSource = paperSources.Cast<System.Drawing.Printing.PaperSource>().SingleOrDefault(ps => ps.RawKind == 256);
    return paperSource.ToAsposePaperSource();