Copies from PrinterSettings is not working during print

Hi June,


Thanks for your inquiry. I have printed a sample landscape with setting AutoRotate property to true and ScaleFactor to .5f with latest version of Aspose.Pdf for .NET 10.0.0 to XPS document printer. It is scaling the print but with incorrect results. We will appreciate it if you you please share your sample code and sample input/output file here. So we will investigate it and address your issue exactly.

We are truly sorry for the inconvenience caused.

Best Regards,

Hi,

I am encountering the copies issue on the latest version of Aspose.PDF (22.7), the issue arose on 21.7 however upon upgrading to 22.7 I am having the same problem, it appears to only happen when using Microsoft Print to PDF as the printer and it does NOT occur when I use Adobe PDF for printing. Also to note, this has been reproduced for all our users.

@aaron.biggs

Would you kindly share your sample PDF document with sample code snippet with us? We will test the scenario in our environment and address it accordingly.

You can use any PDF (non PDF-A), but below is the code snippet:

    var printerSettings    = new PrintDocument().PrinterSettings;

    if (displayPrintDialog)
    {
      PrintDialog dialog = new PrintDialog();
      dialog.AllowSomePages   = true;
      dialog.AllowCurrentPage = true;
      dialog.UseEXDialog      = true;

      if (dialog.ShowDialog() == DialogResult.OK)
      {
        printerSettings = dialog.PrinterSettings;

        if (printerSettings.PrintRange == PrintRange.CurrentPage)
        {
          printerSettings.FromPage = this.CurrentPage;
          printerSettings.ToPage   = this.CurrentPage;
          printerSettings.PrintRange = PrintRange.SomePages;
        }
      }
    }

  try
  {
    using (PdfViewer viewer = new PdfViewer())
    {
      viewer.BindPdf(FileName);

      if (printerSettings.PrintRange == PrintRange.CurrentPage)
      {
        printerSettings.FromPage = this.CurrentPage;
        printerSettings.ToPage = this.CurrentPage;
      }

      viewer.AutoResize = !PrintActualSize;

      viewer.AutoRotate = AutoRotate;

      PageSettings pageSettings = new PageSettings(printerSettings)
      {
        Margins = new Margins(0, 0, 0, 0) // We need to make sure the margins are set to 0
      };

      if (!String.IsNullOrEmpty(PrintTray) && int.TryParse(PrintTray, out int rawKind))
      {
        foreach (PaperSource source in printerSettings.PaperSources)
        {
          if (source.RawKind == rawKind)
          {
            pageSettings.PaperSource = source;
          }
        }
      }

      viewer.PrinterJobName = DocumentName;

      viewer.PrintDocumentWithSettings(pageSettings, printerSettings);

      // Exceptions at print time do not get thrown, check for such exceptions
      if (viewer.PrintStatus != null)
      {
        throw new Exception("...");
      }
      viewer.Close();

PrintTray was passed in but you can ignore that section, the result is the same

@aaron.biggs

Would you please confirm if you are facing the similar issue as described above (in the first post of this thread)?

Yep, that’s the same issue I’m having.

@aaron.biggs

We are checking it and will get back to you shortly.

@aaron.biggs

Can you please try using 23.1 version of the API and let us know in case you still notice any issues?