Added suffix to GetParagraphHeight to calculate the height of the Continue Message.

Added ContinueHeight property to calculate tthe height of the Section continue message.
This commit is contained in:
Rich
2015-02-26 18:48:29 +00:00
parent 5d227213c5
commit 6732e6c9fc
5 changed files with 39 additions and 12 deletions

View File

@@ -125,21 +125,21 @@ namespace Volian.Print.Library
{
int profileDepth = ProfileTimer.Push(">>>> vlnPrintObject.Height");
if (_Height == 0)
_Height = GetParagraphHeight(MyContentByte, IParagraph, Width);
_Height = GetParagraphHeight(MyContentByte, IParagraph, string.Empty, Width);
ProfileTimer.Pop(profileDepth);
return _Height;
}
set { _Height = value; }
}
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width)
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width)
{
return GetParagraphHeight(cb, iParagraph, width, true);
return GetParagraphHeight(cb, iParagraph, suffix, width, true);
}
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException)
public float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException)
{
VlnSvgPageHelper ph = null;
if(cb != null) ph = cb.PdfWriter.PageEvent as VlnSvgPageHelper;
float heightAll = GetHeight(cb, iParagraph, width, throwException);
float heightAll = GetHeight(cb, iParagraph, suffix, width, throwException);
if (ph != null && ph.MyPromsPrinter.DebugOutput && !MyPageHelper.Back32BitPROMS)
{
vlnParagraph myParagraph = this as vlnParagraph;
@@ -192,11 +192,20 @@ namespace Volian.Print.Library
}
return chk;
}
public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException)
public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException)
{
ColumnText myColumnText = new ColumnText(cb);
myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin
myColumnText.AddElement(iParagraph);
if (suffix != string.Empty)
{
Chunk chk = iParagraph.Chunks[0] as Chunk;
iParagraph.Add(new Chunk(suffix, chk.Font));
myColumnText.AddText(iParagraph);
}
else
{
myColumnText.AddElement(iParagraph);
}
//myColumnText.UseAscender = true;// Adjusts to the top of the text box.
int status = myColumnText.Go(true); // Check to see if it will fit on the page.
if (ColumnText.HasMoreText(status) && throwException)
@@ -207,13 +216,13 @@ namespace Volian.Print.Library
public float GetTableWidth(PdfContentByte cb, Paragraph iParagraph, float? maxWidth)
{
int iWidth = (int)(maxWidth ?? 72 * 8.5F);
float h = GetParagraphHeight(cb, iParagraph, iWidth);
float h = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth);
int iWidthMax = iWidth; // maximum width in Characters
int iDelta = iWidth / 2;
iWidth = iWidth / 2;
while (iDelta > 0)
{
float h2 = GetParagraphHeight(cb, iParagraph, iWidth,false);
float h2 = GetParagraphHeight(cb, iParagraph, string.Empty, iWidth,false);
iDelta = iDelta / 2;
if (h2 == h) iWidthMax = iWidth;
iWidth += (h2>h ? 1: -1) * iDelta;