views:

903

answers:

3

I am writing a report, which exports nicely to PDF. However, it does not export to a Word document (.doc) properly.

(Margins get ignored in the header area, which messes up pages breaks, footer text is missing, etc.)

To work around this, I want to disable, enable and/or re-size a few items in my report depending on if it is rendered as a PDF or a Word Document.

Is there any way to set an items properties, based on how a report is rendered?

+2  A: 

I think the only solution to your problem is this: in your report you can access Globals.ReportServerUrl. When calling a report you can specify its render type (and even other stuff like dimensions etc) in the URL. All you need to do is write some Custom Code to extract the render type from the URL and you're done.

For more info on all the possible URL parameters go here: http://technet.microsoft.com/en-us/library/ms154040.aspx

Gerrie Schenck
Not as simple as I was hoping for, but it works :) Thank you!
Sophia
A: 

Along the same line of thought, I am attempting to do the same thing, but via the ASP.NET Report Viewer control. The export types are controlled using the built-in drop-down box in the Report Viewer's toolbar.

The ReportServerUrl, unfortunately, does not appear to get these render type indicators embedded in it.

Any ideas for this situation?

I have some items I want to turn off for HTML rendered reports, but show for PDF exported reports.

Jason
A: 

I had a similar scenario I needed to use the report viewer control in an asp.net app. The solution I came up with, was hiding the toolbar in the report viewer control, and creating my own drop-down selector for the various formats (PDF, Excel are the two we currently use).

The workaround is, when loading the report viewer control, I pass an additional paramter to my reports indicating "RenderType=HTML". When the request is made to get say the PDF Version, I use the same methodology, except I use the ServerReport.Render() function and pass "PDF as the RenderType Parameter, same for Excel.

This allows me to do conditional formatting/showing/hiding stuff in my reports for the various report formats.

Because the Report Viewer Webcontrol supports functionality for rendering specific pages/zooms from the code behind etc, it was pretty easy to build our own "toolbar" for manipulating the report, and gave us the advantage of styling it more suitable for our application, (although this can be done with css anyways). Another issue it solved was the weird print feature requiring the active x component, we implemented our own print mechanism to write the report out in a printer friendly manner.

Hope this helps.