Has anyone figured out a way to render a Reporting Services report at a resolution greater than 96ppi?
Asked Answered
V

6

5

I've tried everything I can think of to change the rendering parameters for a report that I need to render as a 300ppi TIFF.

Here's one of several attempts using the URL approach. As we went from 96ppi to 300ppi the size of the 8.5 x 11 image increases dramatically, but the resolution remainded at 96ppi.

//s0550284/ReportServer?/ERecordingReports/Report1&rs:Format=IMAGE&rc:DpiX=300&rc:DpiY=300&rc:PageHeight=11in&rc:PageWidth=8.5in&rs:Command=Render

We've tried changing the SSRS configuration files to change the default from 96ppi to 300ppi, but the change is ignored.

It's starting to look like someone hardcoded 96ppi somewhere where it can't be overridden.

We're running SQL Server 2008 R2.

Any thoughts about how to get past this problem would be very much appreciated.

-Tom

Voletta answered 26/8, 2010 at 18:8 Comment(4)
See if the undocumented PrintDpiX/Y settings mentioned on this MSDN thread help any. I don't have a local SSRS 2008 server setup here, so I wasn't able to check if it was any use myself, but maybe it'll let you make some progress on the issue.Bourg
Tim - some interesting analysis there (they went off on a bit of a tangent), but it doesn't really seem to solve the problem. Thank you! -TomVoletta
You may want to check out infoq.com/articles/Gogolowicz-Swanson-SSRS. It doesn't give you the answer, but it does show how someone managed to deliver 300 dpi for images for non-HTML renders.Cadenza
the correct way - I found by experimentation and some very poorly written documentation at Microsoft - is not rc:DpiX but as follows: &rs:DeviceInfo=<DpiX>300<%2FDpiX><DpiY>300<%2FDpiY> see my post below. This is much easier than the accepted answer.Dyan
V
8

With the assistance of respondants here and in other forums, I found a simple hack that seems to solve my problem. It came to me after I gave up the fight with SSRS. I'm sure that there are lots of perfectly valid reasons as to why SSRS handles different resolution parameters as it does. Frankly, I don't give a hoot. I just need my document generated at the size and resolution I specified.

Here's the relevant pieces of code (error handling removed for the sake of brevity). I invoke SSRS via the web service interface, generate the report, and render it as 300 x 300 TIFF. The results are temporarily saved. It will have been generated as a 96ppi TIFF and scaled up. I then read it in into a BitMap, change the resolution to 300 x 300, and write it back out again. Done.

string deviceInfo = "<DeviceInfo> <OutputFormat>TIFF</OutputFormat> <DpiX>300</DpiX> <DpiY>300</DpiY> <PrintDpiX>300</PrintDpiX> <PrintDpiY>300</PrintDpiY> </DeviceInfo>";
string format = "IMAGE";
Byte[] results;
string mimeType = "image/tiff";

// Generate the report as a TIF
ExecutionInfo ei = new ExecutionInfo();
ei = rsExec.LoadReport(_reportName, historyID);
results = rsExec.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);

string TempFileRSGeneratedTIFF = TempPath + "RSGeneratedTIFF.TIF";

// Save tiff file returned by RS
using (FileStream stream = File.OpenWrite(TempFileRSGeneratedTIFF))
{
    stream.Write(results, 0, results.Length);
}

// Read tif file into bitmap
Bitmap image = new Bitmap(TempFileRSGeneratedTIFF);

// Change the resolution to what it was supposed to be in the first place..
image.SetResolution(300, 300);

// Save the final version of the file
image.Save(DestFileName, System.Drawing.Imaging.ImageFormat.Tiff);

image.Dispose();
Voletta answered 27/8, 2010 at 15:16 Comment(1)
while this works, I did find that there is a way to pass the DpiX and DpiY parameters in the Url, which is much simpler. See my post below.Dyan
C
5

I was able to do this easily in SSRS 2008 R2 by editing the rsreportserver.config file:

      <Extension Name="IMAGE" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering" />
  <Extension Name="TIFF 200 DPI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
    <OverrideNames>
      <Name Language="en-US">TIFF 200 DPI</Name>
    </OverrideNames>
    <Configuration>
      <DeviceInfo>
        <ColorDepth>32</ColorDepth>
        <DpiX>200</DpiX>
        <DpiY>200</DpiY>
        <OutputFormat>TIFF</OutputFormat>
      </DeviceInfo>
    </Configuration>
  </Extension>
  <Extension Name="TIFF 300 DPI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering">
    <OverrideNames>
      <Name Language="en-US">TIFF 300 DPI</Name>
    </OverrideNames>
    <Configuration>
      <DeviceInfo>
        <ColorDepth>32</ColorDepth>
        <DpiX>300</DpiX>
        <DpiY>300</DpiY>
        <OutputFormat>TIFF</OutputFormat>
      </DeviceInfo>
    </Configuration>
  </Extension>

Note that I left the original IMAGE extension intact (although I didn't have to) and added two more references to that extension - one at 200 DPI and one at 300 DPI. All three now show up in the export drop down list in Report Manager and work correctly. Note that (by following Micorsoft's example) I included the ColorDepth attribute although SSRS ignores it. Also note that I used the Language parameter in the Name attribute. The article I was looking at says that the override configuration will be ignored if it doesn't include the Language parameter (didn't test it).

Combings answered 1/8, 2013 at 21:17 Comment(2)
Hi, how can you specify to use this Extension inside your report? I have an image taken from database inside a table but I don't know how to force the image to be rendered like tiff 200 dpi. Thank you!Vitiligo
Very nice. We're running SSRS 2016, and I did not have to restart the service. The changes were immediate and I could select the extension from the export drop down.Ester
D
2

I tried @Chuck Brevitt's method, but Reporting Services from the Web API didn't seem to be honouring the DPI settings for PDF settings. I found by experimentation and some hints in Microsoft notes that this worked:

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>
Dyan answered 19/5, 2017 at 11:53 Comment(0)
F
1

Try restarting your ReportServer after making the changes in the configuration file. Follow the below link.

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/2b1379e1-cbc5-4764-8f39-f043b334244d/rendering-a-report-in-tiff-at-300ppi?forum=sqlreportingservices

I am not quite sure about trying to change the resolution once you have the image exported.

Fierro answered 3/2, 2014 at 16:54 Comment(0)
E
0

Setup the image object to be external (link on report server) or in the database, versus embedded within the report.

Edraedrea answered 19/8, 2015 at 16:37 Comment(0)
V
0

I tried everything under the sun for SSRS 2012, and I mean everything. But eventually I gave up on it as well. Along the same lines of Tom and a ton of googling I found http://csharphelper.com/blog/2017/09/change-image-resolution-c/

This is the working model:

public static string BumpUpResolution(string filename, float dpiX, float dpiY, string processID)
    {
        int oldWidth = 0, oldHeight = 0;

        Bitmap image = new Bitmap(filename);
        oldWidth = image.Width;
        oldHeight = image.Height;

        using (Bitmap bm = new Bitmap(oldWidth, oldHeight))
        {
            Point[] points = {
                             new Point(0,0),
                             new Point(oldWidth, 0),
                             new Point(0, oldHeight),
                         };

            using (Graphics gr = Graphics.FromImage(bm))
            {
                gr.DrawImage(image, points);
            }

            bm.SetResolution(dpiX, dpiY);

            bm.Save(Path.Combine(Path.GetDirectoryName(filename), string.Format("{0}{1}", processID, Path.GetExtension(filename))), System.Drawing.Imaging.ImageFormat.Tiff);
        }

        image.Dispose();
        return Path.Combine(Path.GetDirectoryName(filename), string.Format("{0}{1}", processID, Path.GetExtension(filename)));
    }
Venola answered 10/11, 2017 at 22:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.