16
votes

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.

8

8 Answers

9
votes

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.

3
votes

You can use Pre_render event in Report Viewer.

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

Take a look at this post

Example Remove save As in SSRS

2
votes

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

1
votes

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();
});
0
votes

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);
            });
        });
    }
0
votes

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> 
-1
votes

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.