diff --git a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs
index 7ff0a28a..19b23934 100644
--- a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs
+++ b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs
@@ -11,6 +11,7 @@ using Itenso.Rtf.Interpreter;
using Itenso.Rtf.Support;
using Microsoft.Win32;
using Volian.Base.Library;
+using System.Text.RegularExpressions;
namespace Volian.Print.Library
{
@@ -307,12 +308,59 @@ namespace Volian.Print.Library
{
// The bullet character for some unknown reason was entered in a text font rather than a symbol font
// switch from x25cf ot x2022 moves to a valid bullet character in the text font
- Chunk chk = new Chunk(visualText.Text.Replace("\u25cf", "\u2022"), font);
- AdjustChunk(visualText, font, chk);
- _MyParagraph.Add(chk);
+ ProcessMeans(visualText, visualText.Text.Replace("\u25cf", "\u2022"), font);
}
ProfileTimer.Pop(profileDepth);
}
+ ///
+ /// Method to process means from text. Draws a line above the content of the range included in the
+ /// square brackets. [Mean X]
+ /// Handles everything except font style changes within the expression.
+ ///
+ ///
+ ///
+ ///
+ private void ProcessMeans(IRtfVisualText visualText, string txt,iTextSharp.text.Font font)
+ {
+ Match m = Regex.Match(txt, "(.*)[[]Mean (.+)[]](.*)", RegexOptions.IgnoreCase);
+ Chunk chk;
+ if (m.Groups.Count == 4) // If the text contains [Mean ...] then follow the code to add a line above the text.
+ {
+ //The first group is the text before the last [Mean ...]
+ ProcessMeans(visualText, m.Groups[1].Value, font);// Recursively process the first group.
+ // The second group is the text within the [Mean ...] range
+ chk = new Chunk(m.Groups[2].Value, font);
+ float offset = .8f;// This is just above the character.
+ // If the content is lower case and does not have ascenders then move the line down.
+ if (Regex.IsMatch(m.Groups[2].Value, "^[acgmnopqrsuvwxyz]+$"))
+ offset = .6F;
+ //PrintOverride.CompressPropSubSup = true;
+ if (visualText.Format.SuperScript < 0)// Adjust line for subscript
+ {
+ offset -= .2f;
+ if (PrintOverride.CompressPropSubSup) offset += .2f;// Adjust line for shrinking font
+ }
+ if (visualText.Format.SuperScript > 0)//Adjust line for superscript
+ {
+ offset += .3f;
+ if (PrintOverride.CompressPropSubSup) offset += .2f;// Adjust line for shrinking font
+ }
+ // Draw the line
+ chk.SetUnderline(font.Color, 0, .05F, 0, offset, PdfContentByte.LINE_CAP_ROUND);
+ AdjustChunk(visualText, font, chk);
+ _MyParagraph.Add(chk);
+ // output the text following the [Mean ...]
+ chk = new Chunk(m.Groups[3].Value, font);
+ AdjustChunk(visualText, font, chk);
+ _MyParagraph.Add(chk);
+ }
+ else
+ {
+ chk = new Chunk(txt, font);
+ AdjustChunk(visualText, font, chk);
+ _MyParagraph.Add(chk);
+ }
+ }
private void AdjustChunk(IRtfVisualText visualText, iTextSharp.text.Font font, Chunk chk)
{
if (visualText.Format.BackgroundColor.AsDrawingColor.ToArgb() != System.Drawing.Color.White.ToArgb())