In Reporting Services, increase the quality of the background image above 96 dpi
Asked Answered
M

3

7

I'd like to use a background image, and when I put it in Reporting Services 2008 R2, the image dpi is reduced to 96 dpi. (instead of 300)

That's too low to be readable by the user, I fear.

When I go on the Internet, I find this result :

http://social.technet.microsoft.com/Forums/en-US/sqlreportingservices/thread/48de91f9-1844-40c1-9614-5ead0b4b69a5#P1Q14

Question 14: How to improve PDF quality of the report exported in Reporting Services 2005?

Answer: The PDF renderer in Reporting Services 2005 resizes all images that it is given at 96 DPI no matter what DPI the image is when you pass it to the renderer. That means that a 300 DPI image or even a 600 DPI image will be sized in the PDF as if it is only 96 DPI. In other words, your high DPI image may render larger than expected.
Despite sizing the images as if they were 96 DPI, the PDF renderer appears to render higher DPI images at a higher quality than 96 DPI. Even if the sizing being wrong, the image actually is rendering at a higher quality. A necessary workaround is to size the image to the proper number of inches based on 96 DPI calculations. Then use Bitmap.SetResolution to set the images to at least 300 DPI. That may provide a higher quality image that is the proper number of pixels to fit properly in the report.

But I don't know how to use that Bitmap.SetResolution, I'm using the classic report viewer web control and I need really a fully functional pdf export.

PS : Maybe that issue is resolved in Reporting Services 2012. Does someone has some informations ?

Regards

Moradabad answered 7/12, 2012 at 14:11 Comment(0)
M
4

I found a webpage which explain how to export PDF with a good dpi. http://codeproject.com/Articles/95750/High-fidelity-printing-through-the-SSRS-Report-Vie

The key is to initialize the deviceInfo string with a xml code

       var sb = new System.Text.StringBuilder(1024);
       var xr = System.Xml.XmlWriter.Create(sb);
       xr.WriteStartElement("DeviceInfo");
       xr.WriteElementString("DpiX", "296");
       xr.WriteElementString("DpiY", "296");
       xr.Close();

        deviceInfo = sb.ToString();

        rsExec.SetExecutionParameters(parameters, "fr-fr");

        results = rsExec.Render(format, deviceInfo,
                  out extension, out encoding,
                  out mimeType, out warnings, out streamIDs);

In this case, this solution works. I can generate a pdf file with the good dpi BUT the print button with activex doesn't work (this shouldn't be a problem) and the export button either. I have to add a download button to print. that's a partial solution imho

Moradabad answered 7/12, 2012 at 15:37 Comment(0)
C
1

If you use the WebAPI interface to Reporting Services, I found this way works:

In order to get better PDF rendering of Images, pass the Device Info like this: http://serverName/ReportServer?/pathtoReport/ReportName&InvoiceIdOrOtherParameter=24013&rs:Command=Render&rs:Format=PDF&rs:DeviceInfo=<DpiX>300<%2FDpiX><DpiY>300<%2FDpiY>

Constructivism answered 19/5, 2017 at 11:57 Comment(0)
T
0

The answers above led me to this, but I wanted to clarify for those using different coding platforms. The goal is to build the following string to be sent as the DeviceInfo parameter:

    DeviceInfo = '<DeviceInfo><DpiX>300</DpiX><DpiY>300</DpiY></DeviceInfo>'

By doing this, I was able to use a 300dpi image as a background image and render correctly to pdf, although you'll want to find a way to hide the image while you are designing in reportviewer as the preview still shows it much larger.

Tyra answered 8/7, 2020 at 21:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.