Font size not displayed properly in asp.net mvc reportviewer for programmatically created Fast Repor
Hi! I am using FastReport with my ASP.Net MVC application. I am creating report programmatically and showing it in report viewer. Report is generated and displayed in report viewer but font size is different than what I set in code. I have checked auto generated CSS in browser, it showing font size in pixel. I have set font size to "16 px" in code but in browser(report viewer) it shows "21 px".
I have used following code in controller to set font size:
float width = 300;
float height = 200;
/* Creating report */
FastReport.Report rpt = new FastReport.Report();
/* Adding page in report */
FastReport.ReportPage rptPage = new FastReport.ReportPage();
rptPage.Name = "Page1";
rptPage.Width = FastReport.Utils.Units.Inches * width;
rptPage.Height = FastReport.Utils.Units.Inches * height;
rptPage.LeftMargin = 0f;
rptPage.TopMargin = 0f;
rptPage.BottomMargin = 0f;
rptPage.RightMargin = 0f;
rptPage.PaperWidth = FastReport.Utils.Units.Inches * width;
rptPage.PaperHeight = FastReport.Utils.Units.Inches * height;
rpt.Pages.Add(rptPage);
/* Adding band in page */
FastReport.DataBand dataBand = new FastReport.DataBand();
dataBand.Name = "Data1";
dataBand.Width = FastReport.Utils.Units.Inches * width;
dataBand.Height = FastReport.Utils.Units.Inches * height;
rptPage.Bands.Add(dataBand);
/* Adding objects in data band */
FastReport.TextObject txt;
var objFont = new System.Drawing.Font(field.FontName, 16, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
txt = new FastReport.TextObject();
txt.Font = objFont;
txt.Text = "Some text here" ;
txt.Width = 50;
txt.Height = 50;
dataBand.Objects.Add(txt);
FastReport.Web.WebReport webReport = new FastReport.Web.WebReport(); // create object
webReport.Width = Convert.ToInt32(FastReport.Utils.Units.Inches * width);
webReport.Height = Convert.ToInt32(FastReport.Utils.Units.Inches * height);
webReport.Report = rpt;
ViewBag.WebReport = webReport; // send object to the View
Don't know why font size is different than what is set in code.
Thanks :-)
I have used following code in controller to set font size:
float width = 300;
float height = 200;
/* Creating report */
FastReport.Report rpt = new FastReport.Report();
/* Adding page in report */
FastReport.ReportPage rptPage = new FastReport.ReportPage();
rptPage.Name = "Page1";
rptPage.Width = FastReport.Utils.Units.Inches * width;
rptPage.Height = FastReport.Utils.Units.Inches * height;
rptPage.LeftMargin = 0f;
rptPage.TopMargin = 0f;
rptPage.BottomMargin = 0f;
rptPage.RightMargin = 0f;
rptPage.PaperWidth = FastReport.Utils.Units.Inches * width;
rptPage.PaperHeight = FastReport.Utils.Units.Inches * height;
rpt.Pages.Add(rptPage);
/* Adding band in page */
FastReport.DataBand dataBand = new FastReport.DataBand();
dataBand.Name = "Data1";
dataBand.Width = FastReport.Utils.Units.Inches * width;
dataBand.Height = FastReport.Utils.Units.Inches * height;
rptPage.Bands.Add(dataBand);
/* Adding objects in data band */
FastReport.TextObject txt;
var objFont = new System.Drawing.Font(field.FontName, 16, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
txt = new FastReport.TextObject();
txt.Font = objFont;
txt.Text = "Some text here" ;
txt.Width = 50;
txt.Height = 50;
dataBand.Objects.Add(txt);
FastReport.Web.WebReport webReport = new FastReport.Web.WebReport(); // create object
webReport.Width = Convert.ToInt32(FastReport.Utils.Units.Inches * width);
webReport.Height = Convert.ToInt32(FastReport.Utils.Units.Inches * height);
webReport.Report = rpt;
ViewBag.WebReport = webReport; // send object to the View
Don't know why font size is different than what is set in code.
Thanks :-)
Comments
Thanks :-)