1

Here is my code:

   public string PrintPdfAspose(string printerName)
        {
            // For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
            // The path to the documents directory.
            string dataDir = filePath;

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

            // Open input PDF file
            viewer.BindPdf(dataDir);


            viewer.PrintDocumentWithSettings(pgs, ps);
            // Check the print status
            if (viewer.PrintStatus != null)
            {
                // An exception was thrown
                Exception ex = viewer.PrintStatus as Exception;
                if (ex != null)
                {
                    return ex.ToString();
                }
            }
            else
            {
                // No errors were found. Printing job has completed successfully
                viewer.Close();
                return "printing completed without any issue..";

            }

        }

I am always getting for PrintStatus null, I should get some kind of error when printer is not printing for some reason. Any help?

  • Would you please share a narrowed down sample application via Google Drive, Dropbox etc., which reproduces this issue; as there are some undeclared variables involved in your code snippet. We will try to reproduce and investigate it in our environment to help you out. Before sharing requested data, please ensure using Aspose.PDF for .NET 18.8. **PS:** I work with Aspose as Developer Evangelist. – Farhan Raza Sep 03 '18 at 21:53
  • Here is my full code: https://pastebin.com/Nv4gp2PL – Kristijan Apostolov Sep 04 '18 at 11:04
  • We have called the method as *PrintPdfAspose("Microsoft Print to PDF");* and it executes fine, without any problem. Please test it with Aspose.PDF for .NET 18.8 and check if this is file specific problem or not. If the issue still persist then please share a sample project reproducing this issue along with the source PDF file so that we may proceed to help you out. – Farhan Raza Sep 04 '18 at 17:22

0 Answers0