ReportViewer - Hide PDF Export

Lennie picture Lennie · Sep 30, 2009 · Viewed 47.6k times · Source

I make use of a ReportView component in a VB.Net 2005 app. How can I disable the PDF export functionality, only keeping the MS Excel format?

Answer

MMalke picture MMalke · Feb 8, 2012

I had exactly the same problem and solved using the following C# method, found here!:

public void DisableUnwantedExportFormat(ReportViewer ReportViewerID, string strFormatName)
{
    FieldInfo info;

    foreach (RenderingExtension extension in ReportViewerID.LocalReport.ListRenderingExtensions())
     {
        if (extension.Name == strFormatName)
        {
             info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
            info.SetValue(extension, false);
        }
    }
}

and on the page_load:

DisableUnwantedExportFormat(ReportViewer1, "PDF");