Font size not displayed properly in asp.net mvc reportviewer for programmatically created Fast Repor

edited 2:47PM in FastReport .NET
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 :-)



Comments

  • edited 2:47PM
    Any update. Is something wrong in my above code. Please inform me what is wrong, why font size is not display as what I set in code.

    Thanks :-)

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.