Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace font size in HTML

Status
Not open for further replies.

tjjames

IS-IT--Management
Aug 26, 2021
3
GB
I have a text field that sometimes need needs to be interpreted as HTML, and sometimes as RTF. To this end I have the following in the text interpretation formula:

if left ({x_clinical_notes.note}, 5) = '{\rtf' then crRTFtext else crHTMLtext

This works, but the problem I have is that the font in the source can vary in size, however I want it to always be font size 8 in my report. Setting the font size of the field in my report doesn't always seem to work when the source is HTML and the font size defaults to the font size in the HTML as in the highlight section below, this would display as size 16, not 8.

<h1 class="x-title-page" style="box-sizing: border-box; padding: 0px; margin: 0px 0px 6px; [highlight #FCE94F]font-size:
16px[/highlight]; line-height: 30px; height: 30px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
color: rgb(49, 51, 54);"><span data-bind="text: prescribingData.overlayTitle" style="box-sizing:
border-box; padding: 0px; margin: 0px; font-weight: normal;"><font face="Arial">Patient said he
takes BISOPROLOL FUMARATE 7.5 mg Tablets in the morning</font></span></h1>

Is it possible to always force this field to display as size 8? I was able to get the desired results using a formula with:

replace ({x_clinical_notes.note}, "font-size: 16px", "font-size: 8px")

However, the source font size could be anything and not just 16px.


 
I think what you probably want to do is use InStr in a loop to look for the "font-size:" tag and then replace whatever the value is with "8px" when you find it. The formula might look something like this:

Code:
Local StringVar inString := {x_clinical_notes.note};
Local NumberVar i := InStr(inString, 'font-size:');
Local StringVar result := ;
If i > 0 then
  While i <= Length(inString) And i > 0 Do
  (
     result := left(inString, i + 11) + '8px;'; //original string through "font-size:"
     i := InStr(i, inString, ';'); //find the end of this font-size 
     inString := mid(inString, i, Length(inString));
     i := InStr(inString, 'font-size:');
  );
  result := result + inString;  //get the end of the string after all font sizes have been set
else
  result := inString;
result

I wrote this without testing it, so you may need to tweak it a bit, but this is the technique you need.

-Dell

Associate Director, Data & Analytics
Protiviti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top