diff --git a/PROMS/Volian.Print.Library/Grid2Pdf.cs b/PROMS/Volian.Print.Library/Grid2Pdf.cs index 92fb48c4..d6369fee 100644 --- a/PROMS/Volian.Print.Library/Grid2Pdf.cs +++ b/PROMS/Volian.Print.Library/Grid2Pdf.cs @@ -759,6 +759,7 @@ namespace Volian.Print.Library } public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont) { + rtf=FixRTFToPrint(rtf); IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf); Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc); rtf2IText.DefaultFont = mySymFont; @@ -766,6 +767,38 @@ namespace Volian.Print.Library para.SetLeading(_SixLinesPerInch, 0); return para; } + // The text font used in FixRTFToPrint for grid + public static System.Drawing.Font DefaultFont = null; + /// + /// Fix RTF so that text uses the Text font rather than the Symbol font. + /// + /// + /// + private static string FixRTFToPrint(string rtf) + { + // Only do this if the text contains symbols. + if (rtf.Contains("VESymbFix")) + { + System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox(); + rtb.Rtf = rtf; + bool changed = false; + // Look at one character at a time + for (int i = 0; i < rtb.TextLength; i++) + { + rtb.Select(i, 1); + // If the character is a printable character set the font to the text font + if (rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText[0] > ' ' && rtb.SelectedText[0] <= '\xFF') + { + //use bolding underline italics from local font + System.Drawing.Font fnt = rtb.SelectionFont; + rtb.SelectionFont = new System.Drawing.Font(DefaultFont, fnt.Style); + changed = true; + } + } + if (changed) return rtb.Rtf; + } + return rtf; + } private static float _SixLinesPerInch = 12; // twips #endregion #region Public Methods diff --git a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs index 41e9b045..7ff0a28a 100644 --- a/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs +++ b/PROMS/Volian.Print.Library/Rtf2iTextSharp.cs @@ -242,8 +242,27 @@ namespace Volian.Print.Library if (c > '\x7F' && c != '\xA0' && c != '\xB0') return true; return false; } +// The funcction below was used for the first few lines of DoVisitText which have been commented-out + //private object FixText(string str) + //{ + // StringBuilder sb = new StringBuilder(); + // foreach (char c in str) + // if (c < ' ' || c > '\xFF') + // sb.Append(string.Format("[{0}]", (int)c)); + // else + // sb.Append(c); + // return sb.ToString(); + //} protected override void DoVisitText(IRtfVisualText visualText) { + //Code to find text (non-symbol) being output with a symbol font + //if(visualText.Format.Font.Name=="VESymbFix" && visualText.Text.Length > 1) + //{ + // string s = visualText.Text; + // s=s.Replace("a","").Replace("b",""); + // if(s!=visualText.Text) + // Console.WriteLine("{0}-{1}-{2}-{3}", visualText.Format.Font.Name, (int)(visualText.Text[0]),visualText.Text.Length,FixText(visualText.Text)); + //} int profileDepth = ProfileTimer.Push(">>>> DoVisitText"); if (visualText.Format.IsHidden) { @@ -294,7 +313,6 @@ namespace Volian.Print.Library } ProfileTimer.Pop(profileDepth); } - private void AdjustChunk(IRtfVisualText visualText, iTextSharp.text.Font font, Chunk chk) { if (visualText.Format.BackgroundColor.AsDrawingColor.ToArgb() != System.Drawing.Color.White.ToArgb())