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.
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: