PDF print Page from and To setting not working

Hello there,
We are facing problems configuring the PDF print page from and to settings.
We found the below code in our web portal, but after configuring it, it always printing four pages.
Could you please help us fix this issue? We are interested in buying this library ASAP.

Code :
PrinterSettings settings = new PrinterSettings();
var printerinfo = $@“\{printerRequestsDTO.PrintServer}{printerRequestsDTO.PrinterQueue}”;
settings.PrinterName = printerinfo; // Set your printer name here

  // Set number of copies
  settings.Copies = 1; // Set the number of copies here

  // Set page range if needed
  settings.FromPage = 1; // Set the start page
  settings.ToPage = 1;   // Set the end page

  PageSettings pageset = new PageSettings();
  pageset.Landscape = false;


  // Print the document
  viewer.PrintDocument();// (settings);

  // Close the PDF file after printing
  
  viewer.Close();

  return true;

Thanks!

Regards,
Basawa

@Basawaraj_R_Biradar

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-56633

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.

@Basawaraj_R_Biradar

In order to print pages only in the the requested range, the respective value of the PrinterSettings.PrintRange property should be set. The default value, PrintRange.AllPages, ignores PrinterSettings.FromPage and PrinterSettings.ToPage properties by design.

Please refer to the following corrected code snippet:

using (Facades.PdfViewer pdfViewer = new Facades.PdfViewer())
{
    Printing.PageSettings printerPageSettings = new Printing.PageSettings
    {
        Landscape = false
    };
    pdfViewer.AutoResize = true;
    pdfViewer.AutoRotate = true;
    pdfViewer.PrintPageDialog = false;
    pdfViewer.BindPdf(dataDir + "out_optimized.pdf");
    Printing.PrinterSettings ps = new Printing.PrinterSettings();

    // In order to use FromPage and ToPage properties, the PrintRange should be set accordingly
    ps.PrintRange = PrintRange.SomePages;

    ps.FromPage = 1;
    ps.ToPage = 1;
    ps.PrinterName = "Microsoft Print to PDF";
    ps.Copies = 1;
    //pgs.Margins = new Margins(0, 0, 0, 0);
    //pdfViewer.BindPdf(dataDir + "ToPrint.pdf");
    //pdfViewer.PrintAsGrayscale = true;
    ps.PrintToFile = true;
    ps.PrintFileName = dataDir + @"1.pdf";
    pdfViewer.PrintDocumentWithSettings(printerPageSettings, ps);
    //pdfViewer.PrintDocument();
    pdfViewer.Close();
}