How to give dynamic margin in RDLC report


How i can give dynamic margin to the rdlc report in ASP.NET C#?

I have tried this code but it is not working.......

       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);

Thanks


Asked by:- RahulMungra
0
: 4550 At:- 8/11/2021 6:17:28 AM
C# RDLC-report







1 Answers
profileImage Answered by:- vikas_jk

You can give try to this code

   // creates a new page setting
    PageSettings instance = new PageSettings();
    // create the new margin values (left,right,top,bottom)
    Margins value = new Margins(0, 0, 0, 0);
    // gives your new pagesetting a value
    instance.Margins = value;

    // report viewer now sets your margins
    ReportViewer1.SetPageSettings(instance);

Here is similar question with answer

https://social.msdn.microsoft.com/Forums/en-US/7302f8d7-27e9-465b-8adc-74341b74c862/dynamically-setting-margins-on-web-report-viewer-for-a-report?forum=vsreportcontrols

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.

which says as per what I understand you cannot set using C#, but can set margin using JS code

0
At:- 8/11/2021 12:19:03 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use