none
Dynamically setting margins on web report viewer for a report RRS feed

  • Question

  • Dynamically setting margins on web report viewer for a report

     

    I have a requirement to the user to setup margins for a report.  I am using WebForms SSRS viewer control.  Here is how I am trying to set margins

     private void SetupMargins()
            {
                if (topMargin + bottomMargin + leftMargin + rightMargin > 0)
                {
                    System.Drawing.Printing.PageSettings settings = new System.Drawing.Printing.PageSettings();
                    //hundredth of inch
                    settings.Margins.Top = topMargin;
                    settings.Margins.Left = leftMargin;
                    settings.Margins.Bottom = bottomMargin;
                    settings.Margins.Right = rightMargin;
                    MainReportViewer.SetPageSettings(settings);
                }
            }

    :

    This is throwing an exceptions though – Printer not installed on SetPageSettings line.  I know I do not have printer, after all this is running on my web server.  Is there another way to set margins?  If not, how do I get around this exception?

     

     


    Sergey
    Tuesday, August 17, 2010 4:58 PM

Answers

All replies

  • So, we have this issue resolved, but not really to my satisfaction.  We had to install the MS Document Writer as a printer on the web server where report viewer site is hosted and set it as default printer for the user that our Application pool runs under. 

    This seems like a hack, since report viewer should not really care about local printers on the web server, since the report is always printed locally on the client.

     


    Sergey
    • Marked as answer by Sergey Barskiy Tuesday, August 17, 2010 7:54 PM
    • Unmarked as answer by Sergey Barskiy Wednesday, August 18, 2010 3:53 PM
    Tuesday, August 17, 2010 6:50 PM
  • To follow up - this solution does not work still.  Only works if the user that is set as application pool identity is logged on to the web server via Terminal Services.  Does not make much sense to me.

    Any suggestions are appreciated.


    Sergey
    Wednesday, August 18, 2010 3:54 PM
  • I assume that you are running server reports (you said SSRS). Take a look at http://msdn.microsoft.com/en-us/library/ms159195.aspx. Server reports use an ActiveX control to print on the client using JavaScript, and that's also the one you use to set margins and such. This functionality is not available for local (RDLC) reports.


    Cephas Lin This posting is provided "AS IS" with no warranties.
    Thursday, August 19, 2010 3:13 PM
    Moderator