Index: cprs/branches/tmg-cprs/CPRS-Chart/Templates/uTemplateFields.pas
===================================================================
--- cprs/branches/tmg-cprs/CPRS-Chart/Templates/uTemplateFields.pas	(revision 686)
+++ cprs/branches/tmg-cprs/CPRS-Chart/Templates/uTemplateFields.pas	(revision 694)
@@ -5,5 +5,5 @@
 
 uses
-  Forms, SysUtils, Classes, Dialogs, StdCtrls, ExtCtrls, Controls, Contnrs,
+  Forms, SysUtils, StrUtils, Classes, Dialogs, StdCtrls, ExtCtrls, Controls, Contnrs,
   Graphics, ORClasses, ComCtrls, ORDtTm;
 
@@ -454,13 +454,14 @@
 end;
 
-procedure WordWrapText(var Txt: string);
+procedure WordWrapText(var Txt: string; HTMLMode : boolean);
 var
   TmpSL: TStringList;
   i: integer;
 
-  function WrappedText(const Str: string): string;
+  function WrappedText(const Str: string; boolHTMLMode : boolean): string;
   var
-    i, i2, j, k: integer;
-    Temp: string;
+    i, i2, j, k, m: integer;
+    HTMLStrLen : integer;
+    Temp, Temp1, Temp2: string;
 
   begin
@@ -508,5 +509,18 @@
 
     Result := Result + Temp;
-    Result := WrapText(Result, #13#10, [' '], MAX_ENTRY_WIDTH);
+
+    //Count the HTML tag length and add to MAX_ENTRY WIDTH   elh 1-29-10
+    HTMLStrLen := 0;
+    if boolHTMLMode = True then begin
+      temp1 := Result;
+      while (pos('<',temp1)>0) and (pos('>',temp1)>0) do
+      begin
+         temp2 := MidStr(temp1,pos('<',temp1),pos('>',temp1)-pos('<',temp1)+1);
+         HTMLStrLen := HTMLStrLen + strlen(PChar(temp2));
+         temp1 := Rightstr(temp1,strlen(PChar(temp1))-pos('>',temp1));
+      end;
+    end;
+
+    Result := WrapText(Result, #13#10, [' '], MAX_ENTRY_WIDTH+HTMLStrLen);  //added +HTMLStrLen  elh 1-29-10
     repeat
       i := pos(#1, Result);
@@ -527,5 +541,5 @@
         if Txt <> '' then
           Txt := Txt + CRLF;
-        Txt := Txt + WrappedText(TmpSL[i]);
+        Txt := Txt + WrappedText(TmpSL[i],HTMLMode);
       end;
     finally
@@ -635,5 +649,5 @@
   until(i = 0);
   if not AutoWrap then
-    WordWrapText(Result);
+    WordWrapText(Result,HTMLMode);
 
 end;
