Search code examples
asp.net-core-mvcstimulsoft

How to set image size to dynamic in stimulsoft mvc core?


I added images to Stimulsoft designer. I want to set dynamic resize and cangrow. Also change the size of a page report to a5 or a4. How can I solve this problem?

@Html.StiNetCoreViewer(new StiNetCoreViewerOptions()
{
    //Width = Unit.Pixel(794),
    //Height = Unit.Pixel(1123),

    //setPageFormat(200, 500, PageOrientation.PORTRAIT),
    Theme = Stimulsoft.Report.Web.StiViewerTheme.Office2013WhiteBlue,
    Localization = "Localization/fa.xml",
    Actions =
    {
        GetReport = "Print",
        ViewerEvent = "ViewerEvent",

    },
    Appearance =
        {
        RightToLeft=true,
            PageAlignment=Stimulsoft.Report.Web.StiContentAlignment.Center,
            BackgroundColor = System.Drawing.Color.White,
            PageBorderColor = System.Drawing.Color.Blue,
            ShowPageShadow = true,
            ScrollbarsMode = true,
          //  InterfaceType = Stimulsoft.Report.Web.StiInterfaceType.Auto

        },
    Exports =
        {
        ShowExportToDbf = false,
          ShowExportToDif = false,
          ShowExportToHtml= false,
          ShowExportToPowerPoint=false,
          ShowExportToCsv=false,
          ShowExportToDocument = false,
          ShowExportToExcel2007= false,
          ShowExportToImageBmp=false,
          ShowExportToRtf=false,
          ShowExportToImageSvgz=false,
        },
  

})

Solution

  • I solved the problem with the following code:

     foreach (StiPage page in report.Pages)
                {
                    page.Orientation = StiPageOrientation.Portrait;
                    page.Margins.Top = 0;
                    page.Margins.Bottom = 0;
                    page.Margins.Left = 0;
                    page.Margins.Right = 0;
                    page.PaperSize = System.Drawing.Printing.PaperKind.A4;
    
                }
     StiReport report = new StiReport();
     var image = report.GetComponentByName("Image1") as StiImage;
     image.CanGrow = false ;    
     image.Width = 120;