ReportViewer.PrintDialog () throws an exception when printing to Adobe PDF

I am working on a WinForms application that uses a ReportViewer control to display several Reporting Services reports. On these screens, we allow the user to print the report by calling the PrintDialog() method in ReportViewer as follows:

 _reportViewer.PrintDialog(); 

In most cases, this works great, it displays the standard Windows print dialog, the user selects which printer they want to print, and prints. However, when the user selects PDF printing using "Adobe PDF", he throws a Win32Exception: The specified datatype is invalid . The file dialog box to choose where to save the pdf file does not even appear.

This only happens with an Adobe PDF printer. I installed NitroPDF and used their PDF printer and it works without problems.

Does anyone have an idea on what could be causing this?

Edit:

Here is the stack trace:

 at System.Drawing.Printing.StandardPrintController.OnStartPrint(PrintDocument document, PrintEventArgs e) at System.Windows.Forms.PrintControllerWithStatusDialog.OnStartPrint(PrintDocument document, PrintEventArgs e) at System.Drawing.Printing.PrintController.Print(PrintDocument document) at System.Drawing.Printing.PrintDocument.Print() at Microsoft.Reporting.WinForms.ReportViewer.PrintDialog(PrinterSettings printerSettings) at Microsoft.Reporting.WinForms.ReportViewer.PrintDialog() 
+4
source share
3 answers

This does not really fix the problem, but solves it in the eyes of users.

The trap of the error thrown by the PDF printer then calls the Export to PDF functions built into the report services. This is not an error in Winforms even when printing to a PDF printer. From the user's point of view, they are "printed in pdf", as usual, and the experience is identical. Work on it works. :-)

+4
source

AFAIK: The ReportViewer control simply displays each page as a bitmap. Therefore, when printing in PDF format, if the resolution is high, it can be a huge raster image. AdobePDF may have problems with large bitmaps, Adobe has so many other errors! Try lowering the resolution as a test?

I have an application that uses the ReportServer API to receive page bitmaps and breaks them into parts processed by a special print processor

+1
source

Maybe the contents of the report are causing this problem. I want to say that the report may contain certain characters that the Adobe PDF printer cannot recognize.

Can you try to print a very simple / basic / empty report and see if this works.

+1
source

All Articles