PDFsharp: Reading pdf documents created with Microsoft Report Viewer 2010

I’m using the .NET library PDFsharp to merge PDF documents created with Microsoft Report Viewer 2008 into a new PDF document.
After upgrading the Microsoft Report Viewer and using the most recent version 2010 to create the individual PDF documents, the merged document contained only blank pages. It turned out, that PDFsharp is not able to “read” the PDF documents that have been created with Microsoft’s Report Viewer 2010. Thanks to this post I found the solution below.

Passing a (special) deviceInfo parameter to LocalReport.Render disables PDF compression and enables PDFsharp to read the generated PDF documents:

var report = viewer.LocalReport.Render("PDF", "<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>", out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

Comments

  1. Hasan Salameh

    thanks a million, this post saved my ass at work!

Leave a comment

Your email address will not be published. Required fields are marked *

*