20

We have many reports which we use on the website. While exporting some reports as PDF, the file size gets huge and the server crashes due to load. So it would be great if I can disable export to PDF option only for certain problematic reports.

So is there a way to disable certain export options (example: export to PDF) in report viewer 9.0 (SSRS), for individual reports?

Thank you.

user1449265
  • 357
  • 1
  • 2
  • 11

8 Answers8

10

Just in case nobody else said it out loud before here or in linked articles:

The neatiest global solution is to find the rendering engines in the RS config file (mine sits in: C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting Services\ReportServer\rsreportserver.config), go to xml key: Extensions > Render and insert following property at the end of each entry you want to hide:

Visible="false"

Example:

<Extension Name="XML" Type="Microsoft.ReportingServices.Rendering.DataRenderer.XmlDataReport,Microsoft.ReportingServices.DataRendering" Visible="false"/>

Alternatively put <!-- and --> (HTML comment markers) at the beginning and end of the entry.

For individual reports those functions will do the trick.

  • Nice concise answer! – callisto Sep 09 '16 at 06:10
  • 1
    Just to share that is possible to do it for Power BI Report Server (On-Premise). The location of the file should or could be at: _C:\Program Files\Microsoft Power BI Report Server\PBIRS\ReportServer_. It is important to **restart the Report Server instance** at the Report Server Configuration Manager to make it effective. – James Apr 04 '19 at 12:51
6

You can use Pre_render event in Report Viewer.

Take a look at this post, it is the source of the following code

Example Remove save As in SSRS

protected void ReportViewer1_PreRender(object sender, EventArgs e)
{
    DisableUnwantedExportFormat((ReportViewer)sender, "Excel");
    DisableUnwantedExportFormat((ReportViewer)sender, "Word");
} 

public void DisableUnwantedExportFormat(ReportViewer ReportViewerID, string strFormatName)
{
    FieldInfo info;
    foreach (RenderingExtension extension in ReportViewerID.LocalReport.ListRenderingExtensions())
    {
        if (extension.Name.Trim().ToUpper() == strFormatName.Trim().ToUpper())
        {
            info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
            info.SetValue(extension, false);
        }
    }

}
Cleptus
  • 3,446
  • 4
  • 28
  • 34
shamcs
  • 629
  • 6
  • 15
  • 1
    Hi shamcs, Where would I place the above code. I don't think it goes into custom code section of the report – Mark O Keeffe Oct 29 '14 at 09:28
  • @MarkOKeeffe you can follow the link that i give there, on report viewer controller, add action to event OnPreRender. – shamcs Oct 30 '14 at 09:37
2

You can hide PDF button globally in a specific config file here:

"InstallPath\Reporting Services\ReportServer\rsreportserver.config"

For more information, there is already a topic about this on StackOverflow.

Please check for more answers here: ReportViewer - Hide PDF Export

Community
  • 1
  • 1
dn7123
  • 161
  • 1
  • 2
  • 6
  • 1
    Thank you. But wouldn`t disabling globally disable "export to PDF" for all reports? What we want to achieve is to be able to disable the export to PDF only for individual reports. – user1449265 Apr 09 '13 at 09:20
  • The link in the end of my answer contains more solutions for this particular problem without globally disabling PDF exports. – dn7123 Apr 12 '13 at 07:47
1

My solution for this

$(document).ready(function() {
        var sel = $("select#ReportViewer2_ctl01_ctl05_ctl00");
        sel.find("option[value='XML']").remove();
        sel.find("option[value='CSV']").remove();
        sel.find("option[value='IMAGE']").remove();
        sel.find("option[value='MHTML']").remove();
        sel.find("option[value='PDF']").remove();
        sel.find("option[value='EXCEL']").remove();
});
  • This likely worked at the time the question was answered, but doesn't in the newer version of SSRS. See my answer for more information. – R. Salisbury Aug 03 '17 at 15:35
0

This solves the problem (partially for us):

http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/0c680c69-9f7d-42aa-a6b4-b1178eab8adf

user1449265
  • 357
  • 1
  • 2
  • 11
0

I was using the MvcReportViewer library to get SSRS's report viewer in our MVC application. The library does not support User Control lifecycle events, so I was not able to use the PreRender method given by shamcs. The Javascript method described by Ristanovic Marko partially works, but the selectors did not work for the version of SSRS we were using, it requires JQuery to be loaded in the IFrame, and it does not describe a way to do this only for specific reports. Here's what I came up with:

In my ReportViewer partial, I added the following script block:

var frame = $('#reportframe');
var src = frame.attr('src');
frame.attr('src', src + '?showAdditionalExports=' + @ViewBag.ShowExportsAttribute);

In ReportViewerWebForm.aspx, I added another script block:

var urlParams = new URLSearchParams(location.search);
if (urlParams.get('showAdditionalExports') === 'true') {
    document.addEventListener("DOMContentLoaded",
        function() {
            ['Word', 'Excel'].map(function(title) {
                var menuItem = document.querySelector("#ReportViewer1 a[title='" + title + "']")
                    .parentNode;
                menuItem.parentNode
                    .removeChild(menuItem);
            });
        });
    }
R. Salisbury
  • 1,954
  • 16
  • 17
0

You can use a div over that save button and set its properties like below

<div style="
    background-color: white;
    z-index: 100;
    height: 61px;
    position: absolute;
    padding-left: 500;
    padding-left: 36px;
    margin-left: 370px;
    opacity: 0.5;
"></div> 
Raveesh
  • 50
  • 10
-1

The question is not new, but maybe for others with same problem, My answer be useful, too. In web.config => configuration => configSectionssection paste a new config for telerik report, if you don't have:

<section
      name="Telerik.Reporting"
      type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting, Version=11.0.17.118, Culture=neutral, PublicKeyToken=a9d7983dfcc261be"
      allowLocation="true"
      allowDefinition="Everywhere"/>

Use your telerik verion in version attribute. you can find it from Solution Explorer => your project name => References => TelerikReporting => Properties And Also, in <configrations> body, paste:

 <Telerik.Reporting>
<extensions>
  <render>
    <extension name="RTF" visible="false">
    </extension>
    <extension name="PDF" visible="false">
    </extension>
    <extension name="CSV" visible="false">
    </extension>
    <extension name="IMAGE" visible="false">
    </extension>
    <extension name="MHTML" visible="false">
    </extension>
    <extension name="XPS" visible="false">
    </extension>
  </render>
</extensions>
  </Telerik.Reporting>

In code above I disabled any export type, except for Excel.

Elnaz
  • 2,854
  • 3
  • 29
  • 41