Fix the RTF for grid cells so that Text is set to use a Text font rather than a Symbol font.
Added some debug code for testing the function above. After the code was finished, the debug code was commented-out.
This commit is contained in:
@@ -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;
|
||||
/// <summary>
|
||||
/// Fix RTF so that text uses the Text font rather than the Symbol font.
|
||||
/// </summary>
|
||||
/// <param name="rtf"></param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
|
Reference in New Issue
Block a user