C2017-008 Formats now have a grouping allowing us to change a symbol character’s font family, size, style, and/or the actual character
This commit is contained in:
@@ -760,7 +760,7 @@ namespace Volian.Print.Library
|
||||
str = _StatRTB.Rtf;
|
||||
return str;
|
||||
}
|
||||
public static iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont)
|
||||
private iTextSharp.text.Paragraph RtfToParagraph(string rtf, iTextSharp.text.Font mySymFont)
|
||||
{
|
||||
rtf=FixRTFToPrint(rtf);
|
||||
IRtfDocument rtfDoc = RtfInterpreterTool.BuildDoc(rtf);
|
||||
@@ -777,15 +777,36 @@ namespace Volian.Print.Library
|
||||
/// </summary>
|
||||
/// <param name="rtf"></param>
|
||||
/// <returns></returns>
|
||||
private static string FixRTFToPrint(string rtf)
|
||||
private 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;
|
||||
rtb.Rtf = rtf.Replace(@"\u9586?", "<dblbs>");// rename backslash character to avoid RTF confusion
|
||||
string strRTF = rtf;
|
||||
bool changed = false;
|
||||
// C2017-008 - WCN wants the box symbol to look like their checkoff/signoff box
|
||||
// Check for a list of replacement character for symbols in the format file
|
||||
// ReplaceSymbolChars lets you do one or more of the following with a symbol character:
|
||||
// - change the point size
|
||||
// - change the style
|
||||
// - change the font family
|
||||
// - change the symbol character
|
||||
//
|
||||
// below is taken from the BaseAll format file - is currently commentout and there for reference
|
||||
// Wolf Creek (WCN) currently uses this to increase the size of the box symbol
|
||||
//
|
||||
//<!--example of replacing a symbol character (VESymbFix)-->
|
||||
//<!--ReplaceSymbolChars>
|
||||
// <ReplaceChar Unicode=[decimal char #] Replace=[optional char #] Family=[option font family name] Style=[optional font style] Size=[optional font size]>
|
||||
// <ReplaceChar Unicode="9633" Size="20"/> < this will resize the VESYMBFix box character to 20 point>
|
||||
// <ReplaceChar Unicode="9633" Replace="0163" Family ="WingDings 2" Size="16"/> <this will replace the VESYMBFix box char with a 16 point "WingDing 2" char>
|
||||
//</ReplaceSymbolChars-->
|
||||
//
|
||||
// get the list of symbol replacements
|
||||
FormatData fmtdata = (MyFlexGrid.MyDVI != null) ? MyFlexGrid.MyDVI.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData;
|
||||
ReplaceSymbolCharList SymReplaceList = (fmtdata != null && fmtdata.SectData.ReplaceSymbolCharList != null) ? fmtdata.SectData.ReplaceSymbolCharList : null;
|
||||
// Look at one character at a time
|
||||
for (int i = 0; i < rtb.TextLength; i++)
|
||||
{
|
||||
@@ -806,8 +827,26 @@ namespace Volian.Print.Library
|
||||
rtb.SelectionFont = new System.Drawing.Font(DefaultFont, fnt.Style);
|
||||
changed = true;
|
||||
}
|
||||
if (rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText.Length > 0)
|
||||
{
|
||||
foreach (ReplaceChar rc in SymReplaceList)
|
||||
{
|
||||
if (rc.Unicode != null)
|
||||
{
|
||||
char rc_uchar = Convert.ToChar(Convert.ToInt32(rc.Unicode));
|
||||
if (rc_uchar == rtb.SelectedText[0])
|
||||
{
|
||||
//use bolding underline italics from local font
|
||||
System.Drawing.Font fnt = rtb.SelectionFont;
|
||||
System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null) ? rc.Family : fnt.FontFamily.Name, (rc.Size != null) ? (float)rc.Size : fnt.Size, (rc.Style != null) ? (System.Drawing.FontStyle)rc.Style : fnt.Style);
|
||||
rtb.SelectionFont = fntw;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) return rtb.Rtf;
|
||||
if (changed) return rtb.Rtf.Replace("<dblbs>", @"\u9586?");
|
||||
}
|
||||
return rtf;
|
||||
}
|
||||
|
Reference in New Issue
Block a user