Problem printing pdf to a printer

I copied this code from sample:

// Create PdfViewer object
PdfViewer viewer = new PdfViewer();

        // Open input PDF file

        // Set attributes for printing
        viewer.AutoResize = true;         // Print the file with adjusted size
        viewer.AutoRotate = true;         // Print the file with adjusted rotation

        // Create objects for printer and page settings and PrintDocument

        System.Drawing.Printing.PageSettings pgs = new System.Drawing.Printing.PageSettings

            // Set PageSize (if required)
            PaperSize = new System.Drawing.Printing.PaperSize("A4", 827, 1169),

            // Set PageMargins (if required)
            Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0)

        System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
        if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            // Document printing code goes here
            // Print document using printer and page settings
            System.Drawing.Printing.PrinterSettings ps = printDialog.PrinterSettings;
            viewer.PrintDocumentWithSettings(pgs, ps);

        // Close the PDF file after priting

It is erroring out on the viewer.PrintDocumentWithSettings(pgs, ps);

Cannot convert from System.Drawing.Printing.PageSettings to Aspose.pdf.Printing.PageSettings.

I grabbed Aspose.pdf from nuget and installed version 24.2.0. Do I have the correct version for the code sample?

Hello, djk1962!

This forum is about Open-Source solutions, and not about Aspose libraries.
Please publish your question at to get the answer.

I also would like to ask you to attach the link to the code sample provided. This could help us to better understand the reason for such confusion.

Wish you a good one!