Export SQL reports in PDF landscape

2 minute read

I had to create some reports for a customer this week and the layout of the report didn’t satisfied my client. The reports are exported in portrait format and not in landscape format.

 

First part of the report

image

and on the second page I got the rest of my report.

image

 

Very ugly……….

 

How to export a scom report in pdf landscape format?

 Only solution here is to render the pdf in landscape format, so I start googling and found this blog http://www.bictt.com/blogs/bictt.php/2009/03/17/sql-reporting-services-render-pdf-in-a4-1  and also some information msdn http://msdn.microsoft.com/en-us/library/ms156281.aspx 

 

So to resolve our problem we have to add some code in the Rsreportserver.config file that you can find under “Program FilesMicrosoft SQL ServerMSSQL.5Reporting ServicesReportServer”

 

You can specify rendering extension parameters in the RSReportServer configuration file to override default report rendering behavior for reports that run on a Reporting Services report server. You can modify rendering extension parameters to achieve the following objectives:

  • Change how the rendering extension name appears in the Export list of the report toolbar (for example, to change “Web archive” to “MHTML”), or localize the name to a different language.
  • Create multiple instances of the same rendering extension to support different report presentation options (for example, a portrait and landscape mode version of the Image rendering extension).
  • Change the default rendering extension parameters to use different values (for example, the Image rendering extension uses TIFF as the default output format; you can modify the extension parameters to use EMF instead).

 

Locate the render section in the rsreportserver.config file

 Capture

 

We are going to add two extra entries to the export list.

Below the pdf entry paste the following code:

<Extension Name="PDF (A4 Landscape)" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport,Microsoft.ReportingServices.ImageRendering">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <OverrideNames>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <Name Language="en-US">PDF in A4 Landscape</Name>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </OverrideNames>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <Configuration>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <DeviceInfo>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <OutputFormat>PDF</OutputFormat>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PageHeight>8.27in</PageHeight>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PageWidth>11.69in</PageWidth>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DeviceInfo>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </Configuration>

</Extension>

<Extension Name="PDF (A4 Portrait)" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport,Microsoft.ReportingServices.ImageRendering">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <OverrideNames>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <Name Language="en-US">PDF in A4 Portrait</Name>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </OverrideNames>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <Configuration>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <DeviceInfo>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <OutputFormat>PDF</OutputFormat>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PageHeight>11.69in</PageHeight>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <PageWidth>8.27in</PageWidth>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </DeviceInfo>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </Configuration>

</Extension>

``

Save the file and close it. I also did a IIsreset and a restart of my sql reporting services just to be sure.

When I want to export a report I have two extra entries:

image

 

Now when I want to export a report in landscape format I just choose to export in pdf in A4 landscape format and this is the result:

image

 

Everything perfectly fits on one page and I have a happy client now 🙂 !!  Thanks to Bob Cornelissen for his blog.

 

Hope this helps,

Alexandre Verkinderen

Leave a comment