Command Line switch to skip ReplaceWords function (Edit and Print)
Added Hanging Indent Logic for Grids.
This commit is contained in:
@@ -9,6 +9,7 @@ using Itenso.Rtf.Interpreter;
|
||||
using Itenso.Rtf.Support;
|
||||
using Volian.Print.Library;
|
||||
using Volian.Controls.Library;
|
||||
using iTextSharp.text;
|
||||
using iTextSharp.text.pdf;
|
||||
|
||||
|
||||
@@ -212,6 +213,20 @@ namespace Volian.Print.Library
|
||||
str = PreProcessRTF(w, str);
|
||||
iTextSharp.text.Paragraph myPara = RtfToParagraph(str);
|
||||
myColumnText1.SetSimpleColumn(0, 0, w - 2, MyContentByte.PdfDocument.PageSize.Top); // Padding = 4
|
||||
if (str.Contains(@"\'05"))
|
||||
{
|
||||
// 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
|
||||
// create a chunk with that symbol. Then loop through all of the chunks until we find
|
||||
// this symbol, adding up the widths to that point. This width is the value that
|
||||
// needs to be used to set the indent.
|
||||
// Notes:
|
||||
// A hard return will reset the chkW (indent width) back to zero.
|
||||
// We jump out of the processing loop after the first indent token is found and ignor any other ones
|
||||
float chkW = CalculateHangingIndent(str);
|
||||
myPara.IndentationLeft = chkW;
|
||||
myPara.FirstLineIndent = -chkW;
|
||||
}
|
||||
|
||||
// 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:
|
||||
@@ -234,6 +249,28 @@ namespace Volian.Print.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
public static float CalculateHangingIndent(string rtf)
|
||||
{
|
||||
float chkW = 0;
|
||||
IRtfDocument rtfDoc2 = RtfInterpreterTool.BuildDoc(rtf.Replace(@"\'05", @"\f1 \u9999? \f0 "));
|
||||
Rtf2iTextSharp rtf2IText2 = new Rtf2iTextSharp(rtfDoc2);
|
||||
iTextSharp.text.Paragraph para2 = rtf2IText2.Convert();
|
||||
foreach (Chunk chk in para2.Chunks)
|
||||
{
|
||||
if (chk.Content[0] == 9999) break;
|
||||
if (chk.Content.Contains("\u270f"))
|
||||
{
|
||||
int i = chk.Content.IndexOf('\u270F');
|
||||
int n = chk.Content.Length;
|
||||
chkW += chk.GetWidthPoint() * i / (n - i);
|
||||
break;
|
||||
}
|
||||
if (chk.Content.Contains("\n")) chkW = 0; //hard return - reset chkW (indent start)
|
||||
chkW += chk.GetWidthPoint();
|
||||
}
|
||||
return chkW;
|
||||
}
|
||||
|
||||
private static StepRTB _StatRTB = new StepRTB();
|
||||
private string PreProcessRTF(float w, string str)
|
||||
{
|
||||
|
Reference in New Issue
Block a user