PdfViewer.PrintDocument() - detecting timeouts

We’re using Pdf.Kit to generate and print custom PDF documents. Everything works as expected, except when something goes wrong with the user’s default printer or the printer doesn’t respond with a completed message. From what I can tell, the PrintDocument() method waits until it gets a response from the printer to say everything is OK. If this never comes, it just waits indefinitely.


Are there any methods within the Pdf.Kit API that would let me check/detect whether the printer has responded within a period of time and carry on/throw an exception if it doesn’t? Is there anything else I can set/check to know whether the printing has been successful or not and take action accordingly?

Many thanks for any advice…

I should probably say that this is within an ASP.NET application.


Would I be correct in saying that PrintDocument() will use the default printer on the server as opposed to the current user’s PC?

Would anyone have any advice on how I can use Aspose to print using client PC settings? Is this where the PrinterSettings object comes in?

Sorry if these are newbie questions - any help/advice appreciated…

Hi,

First of all, I’m sorry to inform you that Aspose.Pdf.Kit can’t return the status of the printing when the file is printed using PdfViewer class; it only sends the print to the default or specified printer.

Secondly, please share whether you want to print a PDF file to a default printer on the Web Server or you want to show the print dialog box? Are you trying to use the printers settings of the client machine for printing using the remotely hosted web application? Kindly share some more details, so we could help you out accordingly.

We’re sorry for the inconvenience.
Regards,

Thanks for getting back to me Shahzad.


Ideally, we would like our users to be able to choose a printer from their local machine to print with. This is a distributed ASP.NET application and the default printer on the server won’t work at all.

However, the PrintPageDialog property on PdfViewer wasn’t working for me at all (I’ve tried PrintDocument() and PrintDocumentWithSetup() and variations of true/false on the flag, but I see no dialogue). So I had to rely on PrintDocument, which was fine when developing, but I noticed it no longer worked in a testing environment.

But I think the fact that Aspose cannot detect printer status might rule it out for us - well, this particular part anyway. We will still be using Aspose tools to generate the source files.

Thanks for your help. If you could provide some pointers as to why the PrintPageDialog flag isn’t working, I’d appreciate it.

Hi,

I’m sorry to share with you that printer dialog can’t be shown in a web application; this might work in an application deployed locally, but not in a scenario where a web application is hosted on a remote server. However, if you want to print from a Windows Forms application, you can print using printer dialog.

We’re sorry for the inconvenience. If you find any further questions, please do let us know.
Regards,