'SSRS - Disabling export options (eg. PDF) for individual reports
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.
Solution 1:[1]
This solves the problem (partially for us):
Solution 2:[2]
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.
Solution 3:[3]
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);
}
}
}
Solution 4:[4]
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
Solution 5:[5]
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();
});
Solution 6:[6]
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);
});
});
}
Solution 7:[7]
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>
Solution 8:[8]
The question is not new, but maybe for others with same problem, My answer be useful, too. In web.config
=> configuration
=> configSections
section 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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user1449265 |
Solution 2 | Remigiusz Banaszak |
Solution 3 | Cleptus |
Solution 4 | Community |
Solution 5 | Ristanovic Marko |
Solution 6 | R. Salisbury |
Solution 7 | Raveesh |
Solution 8 | Elnaz |