B2015-103: indents (strip out rtf indent commands)

B2015-103:  indents (handle rtf indent commands)
B2015-103:  indents (set/clear ribbon button for indents)
B2015-103: setup rtf string for indents; display small identifying marks for indents
B2015-103: remove page break from ribbon; move indent; support new indent; support for table grid indent
B2015-103: Print for new indents in tables
B2015-103: Print for new indents in paragraphs
This commit is contained in:
2015-08-19 12:18:39 +00:00
parent 49dcdd4f4a
commit a58add8937
9 changed files with 1078 additions and 990 deletions

View File

@@ -12,7 +12,7 @@ using Volian.Controls.Library;
using iTextSharp.text;
using iTextSharp.text.pdf;
using VEPROMS.CSLA.Library;
using System.Text.RegularExpressions;
namespace Volian.Print.Library
{
@@ -433,7 +433,16 @@ namespace Volian.Print.Library
myPara.IndentationLeft = chkW;
myPara.FirstLineIndent = -chkW;
}
Match match = Regex.Match(str, @"\\fi([-0-9]*) ?\\li([0-9]*)");
if (match.Success)
{
float fi = float.Parse(match.Groups[1].Value) / 20; // 72 is dots per inch & 96 is standard DPI (120 is KBR's machine)
float li = float.Parse(match.Groups[2].Value) / 20;
// if there is a hanging indent, the iTextSharp paragraph properties must be set
// to print the indent.
myPara.IndentationLeft = li;
myPara.FirstLineIndent = fi;
}
// RHM 20120925 - Line spacing should be 6 lines per inch. In order to get a valid value
// for TotalLeading you have to set MultipliedLeading first:
myPara.MultipliedLeading = 1.0f;
@@ -617,15 +626,19 @@ namespace Volian.Print.Library
// but the text in that table cell will not be indented. - jsj 10/10/2014
//IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
IRtfDocument rtfDoc2 = null;
if (rtf.Contains(@"\f1\fnil\fcharset0 "))
rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
else
return 0; //rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", ""));
//if (rtf.Contains(@"\f1\fnil\fcharset0 "))
// rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
//else
//{
// first add the symbol font and then surround the indent as above.
rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\par\u9999?\par"));
//}
Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2);
iTextSharp.text.Paragraph para2 = rtf2IText2.Convert();
foreach (Chunk chk in para2.Chunks)
for (int ic = 0; ic < para2.Chunks.Count; ic++)
{
Chunk chk = para2.Chunks[ic] as Chunk;
if (chk.Content[0] == 9999) break;
if (chk.Content.Contains("\u270f"))
{
@@ -634,7 +647,11 @@ namespace Volian.Print.Library
chkW += chk.GetWidthPoint() * i / (n - i);
break;
}
if (chk.Content.Contains("\n")) chkW = 0; //hard return - reset chkW (indent start)
if (chk.Content.Contains("\n"))
{
if (ic < para2.Chunks.Count - 2 && (para2.Chunks[ic + 1] as Chunk).Content.StartsWith("\u270f")) return chkW;
chkW = 0; //hard return - reset chkW (indent start)
}
chkW += chk.GetWidthPoint();
}
return chkW;

View File

@@ -11,6 +11,7 @@ using Itenso.Rtf.Support;
using Volian.Controls.Library;
using VEPROMS.CSLA.Library;
using Volian.Base.Library;
using System.Text.RegularExpressions;
namespace Volian.Print.Library
{
@@ -392,7 +393,7 @@ namespace Volian.Print.Library
rtf2IText.HasIndent = hasIndent;
iTextSharp.text.Paragraph para = rtf2IText.Convert();
para.SetLeading(_SixLinesPerInch, 0);
if (rtf.Contains("\x05"))
if (rtf.Contains("\x05")) // note that this is for existing customer data as of August 2015.
{
// if there is a hanging indent, the iTextSharp paragraph properties must be set
// to print the indent. Replace the indent 'token' with a non-used symbol, this will
@@ -406,6 +407,16 @@ namespace Volian.Print.Library
para.IndentationLeft = chkW;
para.FirstLineIndent = -chkW;
}
Match match = Regex.Match(rtf, @"\\fi([-0-9]*) ?\\li([0-9]*)");
if (match.Success)
{
float fi = float.Parse(match.Groups[1].Value) / 20;
float li = float.Parse(match.Groups[2].Value) / 20;
// if there is a hanging indent, the iTextSharp paragraph properties must be set
// to print the indent.
para.IndentationLeft = li;
para.FirstLineIndent = fi;
}
// Change the chunks to only split on spaces rather than spaces and hyphens
foreach (Chunk chk in para)
{