Font size does not work with html tag

Stimulsoft Reports.WEB discussion
Post Reply
Nuts_ethanol
Posts: 5
Joined: Fri May 08, 2020 4:41 pm

Font size does not work with html tag

Post by Nuts_ethanol »

I have html text that I want to display as below

Code: Select all

string htmlText = "<p style=\"text-align: center;\"><strong><span style=\"font-size: 20px;\">Text <span style=\"text-decoration: underline; font-family: 'times new roman', times, serif;\">dfdsf</span></span></strong></p>\n<p style=\"text-align: center;\">&nbsp;</p>\n<p style=\"text-align: center;\"><strong><span style=\"font-size: 20px;\"><span style=\"text-decoration: underline; font-family: 'times new roman', times, serif;\">dfdf</span></span></strong></p>\n<p style=\"text-align: center;\"><span style=\"color: #ba372a; background-color: #f1c40f;\"><strong><span style=\"font-size: 20px; background-color: #f1c40f;\"><span style=\"text-decoration: underline; font-family: 'times new roman', times, serif;\">aaa</span></span></strong></span></p>";
I generate StiText programmatically in c# and set AllowHtmlTags to true

Code: Select all

stiText.Text.Value = htmlText;
stiText.AllowHtmlTags = true;
Then I generate the rendered report as string and send them to frontend (Angular)

Code: Select all

	    report.Dictionary.Databases.Clear();
            report.RegData(dataSet);
            report.Dictionary.Synchronize();
            report.Render();
            
            return report.SaveDocumentJsonToString();
Frontend

Code: Select all

        this.viewer = new Stimulsoft.Viewer.StiViewer(options, 'StiViewer', false);
        this.report = new Stimulsoft.Report.StiReport();
        
        
        this.report.loadDocument(data);  // data is the rendered report string from backend
        this.viewer.report = this.report;
        this.viewer.renderHtml('viewer');
The font size does not get set correctly. It seems like it's using the default font of StiText to set. But I look at the rendered string sent from backend, the "Font" property does not get assigned. So I'm sure it's because of frontend. (see picture attached)

I'm using Stimulsoft.Reports.Web.NetCore 2018.2.3

Thank you in advance
Attachments
font.png
font.png (7.56 KiB) Viewed 1618 times
Nuts_ethanol
Posts: 5
Joined: Fri May 08, 2020 4:41 pm

Re: Font size does not work with html tag

Post by Nuts_ethanol »

I think I know. It's because of the version. If I use the latest version, the font size and font family will be shown correctly according to the html text.

So after I update the version and export to excel, all texts will set the left side. But text alignment works well when I export to word and pdf.
Attachments
excelText.PNG
excelText.PNG (4.54 KiB) Viewed 1603 times
Lech Kulikowski
Posts: 7339
Joined: Tue Mar 20, 2018 5:34 am

Re: Font size does not work with html tag

Post by Lech Kulikowski »

Hello,

Could you send us a sample that reproduces the issue for analysis?

Thank you.
Post Reply