Fixed logic that determines when a step is continued on next page so that it uses the phonelist length

Fixed logic that counts the number of lines a phone list takes
Added number of lines an item take up in our debug (micro-print) message
This commit is contained in:
John Jenko 2014-08-22 17:07:14 +00:00
parent 9393fc01d4
commit 310fb42c3c
4 changed files with 9 additions and 6 deletions

View File

@ -227,7 +227,7 @@ namespace Volian.Print.Library
// ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
if (MyPageHelper.DidFirstPageDocStyle && (MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnAllButFirstPage) > 0)
yPageSizeNextPage = GetYPageSizeUseOnAllButFirstPage();
if (!KeepWithHeader && !KeepStepsOnPage && YSize - SixLinesPerInch + yEndMsg <= yPageSizeNextPage) // if the entire step can fit on one page, do a page break
if (!KeepWithHeader && !KeepStepsOnPage && YSize - SixLinesPerInch + yEndMsg <= yPageSizeNextPage) // if the entire step can fit on one page, do a page break
{
// Don't want extra line before step
//Console.WriteLine("'PageBreak',2,'Yes','HLS will fit on 1 Page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
@ -436,8 +436,10 @@ namespace Volian.Print.Library
break;
}
// also account for phonelist for locating bottom continue message:
float phoneListHeight = 0;
if (MyItemInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList && MyPageHelper.PhoneListHeight != 0)
myBottomMsgSpace += (MyPageHelper.PhoneListHeight - vlnPrintObject.SixLinesPerInch);
phoneListHeight = MyPageHelper.PhoneListHeight;
ySpaceOnCurPage -= phoneListHeight;
string myTopMsg = docstyle.Continue.Top.Message;
float myTopMsgSpace = ((myTopMsg ?? "") != "") ? 2 * SixLinesPerInch : 0;
@ -554,7 +556,7 @@ namespace Volian.Print.Library
RemoveProcessedParagraphs(myList, yTopNew - yTop);
yTop = yTopNew;
MyPageHelper.ParaBreaks.Add(paraBreak);
ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line.
ySpaceOnCurPage = yPageSize - (myTopMsgSpace + phoneListHeight + SixLinesPerInch); // Allow for continue message and blank line.
//ySpaceOnCurPage = yPageSize - (myTopMsgSpace + SixLinesPerInch); // Allow for continue message and blank line.
//if (paraBreak.YTopMost != paraBreak.YVeryTop && MyPageHelper.TopMessage == null && MyPageHelper.BottomMessage == null)
// ySpaceOnCurPage = yPageSize;

View File

@ -518,7 +518,7 @@ namespace Volian.Print.Library
if (phlist != null && phlist != "")
{
// count lines:
int cl = 1;
int cl = 0;
int indx = phlist.IndexOf("\n");
while (indx > 0)
{
@ -528,6 +528,7 @@ namespace Volian.Print.Library
else
indx = phlist.IndexOf("\n", indx + 1);
}
if (cl == 0) cl = 1; // phone list is a single line without an ending newline
_MyHelper.PhoneListHeight = cl * vlnPrintObject.SixLinesPerInch;
}
}

View File

@ -194,7 +194,7 @@ namespace Volian.Print.Library
ColumnText ct = new ColumnText(cb);
ct.SetSimpleColumn(left, 4 + top - yDescent, right, top - yDescent - 50);
iTextSharp.text.Font font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 2);
Chunk chk = new Chunk(debugText + string.Format(" Top = {0}",top), font);
Chunk chk = new Chunk(debugText + string.Format(", Top = {0}",top), font);
Phrase ph = new Phrase(chk);
ct.AddElement(ph);
cb.SetColorFill(new Color(sysColor));

View File

@ -753,7 +753,7 @@ namespace Volian.Print.Library
IParagraph.Chunks.RemoveAt(0);
}
}
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin);
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo + string.Format(",YLines = {0}",YSize/SixLinesPerInch), yBottomMargin);
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
{ // pagination logic needs to be fixed.
ForcePagination(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation, ref retval);