Breaking Change in Version 23.10 PageSettings.PrinterSettings.PaperSources not existing

Hello,
in Aspose.PDF Version 23.10 you replaced all System.Drawing.Printing dependencies with Aspose.Pdf.Printing. In most cases it can simply be replaced. But we can’t find a substitution for PrinterSettings.PaperSources. The following code can’t be compiled with Version 23.10:

var paperSources = querypagesettingseventargs.PageSettings.PrinterSettings**.PaperSources**;
var paperSource = paperSources.Cast().SingleOrDefault(ps => ps.RawKind == paperSourceRawKind);
querypagesettingseventargs.PageSettings.PaperSource = paperSource;

Do you have any suggestions how to fix this breaking change. Thank you very much in advance.
Best Regards Fabian.

@FK1

You can please use it like below:

Aspose.Pdf.Printing.PaperSource ps = new Printing.PaperSource();
ps.Kind = Printing.PaperSourceKind.Upper;
printerSettings.DefaultPageSettings.PaperSource = ps;

Hello Ali,
thank you for your fast reply. Unfortunatly the PaperSource.Kind is read only:
image.png (20.1 KB)

@FK1

We have logged an internal ticket as below in our issue tracking system to investigate it further.

Issue ID(s): PDFNET-56430

We will let you know as soon as the ticket is resolved. Please spare us some time.

@FK1

Indeed, the PaperSource instances from the System.Drawing.Printing namespace are generated by requesting the printer’s capabilities using native Windows API. As it’s non-portable, and we cannot access in our library, we cannot generate a PaperSources collection on the Aspose.Pdf.Printing.PrinterSettings Class.

So, as per request, the following public APIs will be changed in the v.24.02:

  • Public constructor PaperSource(PaperSourceKind kind, string name) is added and may be used in the following way:
// Create native System.Drawing.Printing.PrinterSetting to query the printer's capabilities
var nativeSettings = new System.Drawing.Printing.PrinterSettings();
nativeSettings.PrinterName = querypagesettingseventargs.PageSettings.PrinterSettings.PrinterName;

var paperSources = nativeSettings.PaperSources;
var paperSource = paperSources.Cast().SingleOrDefault(ps => ps.RawKind == paperSourceRawKind);

// Create Aspose.Pdf.Printing.PaperSource out of the native PaperSource
// Aspose.Pdf.Printing.PaperSourceKind mirrors values of the System.Drawing.Printing.PaperSourceKind to allow easier conversion between types
querypagesettingseventargs.PageSettings.PaperSource = new Aspose.Pdf.Printing.PaperSource((Aspose.Pdf.Printing.PaperSourceKind) paperSource.Kind, paperSource.SourceName);
  • New public static class Aspose.Pdf.Printing.PaperSources is created to provide a collection of predefined paper sources as its properties. It may be used in the following way:
querypagesettingseventargs.PageSettings.PaperSource = Aspose.Pdf.Printing.PaperSources.Cassette;
  • Public setter for the PaperSource.Kind property is added.

Thank you very much for the fast reply and fixing the problem. We looking forward for the new version. Sounds like a good solution.
Best regards.

@FK1

Thanks for kind feedback. We will send a notification as soon as new version of the API is available.

The issues you have found earlier (filed as PDFNET-56430) have been fixed in Aspose.PDF for .NET 24.2.