Added Debug output for Text and Pagination
Renamed DebugText property to DebugInfo Changed logic to determine if the first step of a step section will fit on the current page Change logic to determine if a step will fit on a blank page
This commit is contained in:
parent
719706350b
commit
fbfcae6100
@ -12,6 +12,7 @@ using Itenso.Rtf.Interpreter;
|
|||||||
using Itenso.Rtf.Support;
|
using Itenso.Rtf.Support;
|
||||||
using Volian.Controls.Library;
|
using Volian.Controls.Library;
|
||||||
using VEPROMS.CSLA.Library;
|
using VEPROMS.CSLA.Library;
|
||||||
|
using Volian.Base.Library;
|
||||||
|
|
||||||
namespace Volian.Print.Library
|
namespace Volian.Print.Library
|
||||||
{
|
{
|
||||||
@ -162,31 +163,30 @@ namespace Volian.Print.Library
|
|||||||
|
|
||||||
private float DrawGrid(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation)
|
private float DrawGrid(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation)
|
||||||
{
|
{
|
||||||
if (_TextDebug)
|
//DebugText.WriteLine("{0},'{1}','{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.ShortPath, FormattedText);
|
||||||
Console.WriteLine("{0},{1},'{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText);
|
DebugText.WriteLine("{0},'{1}','{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.ShortPath,MyItemInfo.MyContent.Text);
|
||||||
float retval = Rtf2Pdf.GridAt(cb, MyGrid, XOffset, yLocation, Width, 100, DebugText, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
|
float retval = Rtf2Pdf.GridAt(cb, MyGrid, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float DrawText(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation)
|
private float DrawText(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation)
|
||||||
{
|
{
|
||||||
if (_TextDebug)
|
DebugText.WriteLine("{0},'{1}','{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText);
|
||||||
Console.WriteLine("{0},{1},'{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText);
|
|
||||||
//Console.WriteLine("{0},{1},'{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, IParagraph.Content);
|
//Console.WriteLine("{0},{1},'{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, IParagraph.Content);
|
||||||
float retval = yLocation;
|
float retval = yLocation;
|
||||||
// Check if only one line, i.e. "Height < (1.2F * IParagraph.Leading". The Leading can be for six or seven lines per inch, so the 1.2
|
// Check if only one line, i.e. "Height < (1.2F * IParagraph.Leading". The Leading can be for six or seven lines per inch, so the 1.2
|
||||||
// multiplier accounts for both.
|
// multiplier accounts for both.
|
||||||
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.CenterOneLineOnly && MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null && Height < (1.2F * IParagraph.Leading))
|
if (!MyItemInfo.IsStepSection && MyItemInfo.FormatStepData.CenterOneLineOnly && MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null && Height < (1.2F * IParagraph.Leading))
|
||||||
IParagraph.Alignment = Element.ALIGN_CENTER;
|
IParagraph.Alignment = Element.ALIGN_CENTER;
|
||||||
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugText, yBottomMargin);
|
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin);
|
||||||
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
|
if (retval == 0) // problem occurred - paragraph was not able to be printed on page
|
||||||
{ // pagination logic needs to be fixed.
|
{ // pagination logic needs to be fixed.
|
||||||
cb.PdfDocument.NewPage(); // pagination issue
|
cb.PdfDocument.NewPage(); // pagination issue
|
||||||
yPageStart = yTopMargin + YVeryTop;
|
yPageStart = yTopMargin + YVeryTop;
|
||||||
yLocation = yPageStart - YOffset;
|
yLocation = yPageStart - YOffset;
|
||||||
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
|
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
|
||||||
if(_PaginationDebug) Console.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},{4}", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.DBSequence);
|
DebugPagination.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},{4}", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.DBSequence);
|
||||||
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugText, yBottomMargin);
|
retval = Rtf2Pdf.TextAt(cb, IParagraph, XOffset, yLocation, Width, 100, DebugInfo, yBottomMargin);
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -255,8 +255,7 @@ namespace Volian.Print.Library
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private bool _PaginationDebug = false;
|
//private bool _TextDebug = false; //true; this will turn on a writeline with debug in DrawText()
|
||||||
private bool _TextDebug = false; //true; this will turn on a writeline with debug in DrawText()
|
|
||||||
private float DrawFigure(PdfContentByte cb, float yBottomMargin, float yLocation)
|
private float DrawFigure(PdfContentByte cb, float yBottomMargin, float yLocation)
|
||||||
{
|
{
|
||||||
float retval = yLocation;
|
float retval = yLocation;
|
||||||
@ -270,12 +269,12 @@ namespace Volian.Print.Library
|
|||||||
if (roImage != null)
|
if (roImage != null)
|
||||||
{
|
{
|
||||||
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(roImage.Content);
|
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(roImage.Content);
|
||||||
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugText, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
|
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
private string DebugText
|
private string DebugInfo
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -461,11 +460,8 @@ namespace Volian.Print.Library
|
|||||||
ItemInfo parent = item.ActiveParent as ItemInfo;
|
ItemInfo parent = item.ActiveParent as ItemInfo;
|
||||||
//if (para.MyItemInfo.ItemID == 205)
|
//if (para.MyItemInfo.ItemID == 205)
|
||||||
// Console.Write("");
|
// Console.Write("");
|
||||||
if (_PaginationDebug)
|
DebugPagination.WriteLine("'StepLevel',{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", YVeryTop - yTopMost, YSize, YBottomMost - yTopMost, item.ItemID, item.DBSequence, item.StepLevel, item.MyContent.Type % 10000,
|
||||||
{
|
|
||||||
Console.WriteLine("'StepLevel',{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}", YVeryTop - yTopMost, YSize, YBottomMost - yTopMost, item.ItemID, item.DBSequence, item.StepLevel, item.MyContent.Type % 10000,
|
|
||||||
parent.MyContent.Type % 10000, item.HasCautionOrNote ? 1 : 0, parent.Cautions == null ? 0 : 1);
|
parent.MyContent.Type % 10000, item.HasCautionOrNote ? 1 : 0, parent.Cautions == null ? 0 : 1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private float _YVeryTop = -1;
|
private float _YVeryTop = -1;
|
||||||
public float YVeryTop
|
public float YVeryTop
|
||||||
@ -542,7 +538,8 @@ namespace Volian.Print.Library
|
|||||||
// can the title and the first step fit?
|
// can the title and the first step fit?
|
||||||
// add the first child's size + (the section title's size)
|
// add the first child's size + (the section title's size)
|
||||||
float ySizeIncludingFirst = firstChild.YSize + (firstChild.YTop - YTop);
|
float ySizeIncludingFirst = firstChild.YSize + (firstChild.YTop - YTop);
|
||||||
if (ySizeIncludingFirst > (yLocation - yBottomMargin - SixLinesPerInch)) return 1;
|
//if (ySizeIncludingFirst > (yLocation - yBottomMargin - SixLinesPerInch)) return 1;
|
||||||
|
if (ySizeIncludingFirst > (yLocation - yBottomMargin)) return 1;
|
||||||
}
|
}
|
||||||
return 0; // Don't Paginate (page break) on a Step Section if it's first thing on page
|
return 0; // Don't Paginate (page break) on a Step Section if it's first thing on page
|
||||||
}
|
}
|
||||||
@ -563,7 +560,8 @@ namespace Volian.Print.Library
|
|||||||
string firstStep = "No";
|
string firstStep = "No";
|
||||||
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)
|
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)
|
||||||
firstStep = "Yes";
|
firstStep = "Yes";
|
||||||
if (!ManualPageBreak && mySize+yEndMsg <= yWithinMargins) // Don't Paginate if there is enough room, will fit on page
|
if (!ManualPageBreak && mySize + yEndMsg <= yWithinMargins) // Don't Paginate if there is enough room, will fit on page
|
||||||
|
//if (!ManualPageBreak && mySize + yEndMsg <= yWithinMargins + SixLinesPerInch) // Don't Paginate if there is enough room, will fit on page
|
||||||
{
|
{
|
||||||
//Console.WriteLine("'PageBreak',1,'No','HLS will fit on page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
//Console.WriteLine("'PageBreak',1,'No','HLS will fit on page',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins);
|
ShowPageBreak(-1, "HLS will fit on page", firstStep, YSize, yPageSize, yWithinMargins);
|
||||||
@ -573,7 +571,7 @@ namespace Volian.Print.Library
|
|||||||
|
|
||||||
// YSize includes a blank line after the step which we don't want to include in the page break test, thus the
|
// YSize includes a blank line after the step which we don't want to include in the page break test, thus the
|
||||||
// YSize - SixLinesPerInch:
|
// YSize - SixLinesPerInch:
|
||||||
if (YSize - SixLinesPerInch + yEndMsg < yPageSize) // if the entire step can fit on one page, do a page break
|
if (YSize - SixLinesPerInch + yEndMsg <= yPageSize) // if the entire step can fit on one page, do a page break
|
||||||
{
|
{
|
||||||
// Don't want extra line before step
|
// 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);
|
//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);
|
||||||
@ -609,7 +607,7 @@ namespace Volian.Print.Library
|
|||||||
|
|
||||||
// Less than half a page left, start printing on a new page.
|
// Less than half a page left, start printing on a new page.
|
||||||
//Console.WriteLine("'PageBreak',5,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
//Console.WriteLine("'PageBreak',5,'Yes','HLS will have to split',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
||||||
ShowPageBreak(5, "HLS will have to split", "Yes", YSize, yPageSize, yWithinMargins);
|
ShowPageBreak(3, "HLS will have to split", "Yes", YSize, yPageSize, yWithinMargins);
|
||||||
// Determine items where page break(s) occur
|
// Determine items where page break(s) occur
|
||||||
//BuildPageBreakList(yPageSize, yPageSize - 2 * SixLinesPerInch); // Case Base
|
//BuildPageBreakList(yPageSize, yPageSize - 2 * SixLinesPerInch); // Case Base
|
||||||
BuildPageBreakList(yPageSize, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7
|
BuildPageBreakList(yPageSize, yPageSize); // Case 1 :Works for ES05 Step 15 SubStep 7
|
||||||
@ -680,12 +678,13 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
private void ShowPageBreak(int instance, string message, string breakOrNot, float YSize, float yPageSize, float yWithinMargins)
|
private void ShowPageBreak(int instance, string message, string breakOrNot, float YSize, float yPageSize, float yWithinMargins)
|
||||||
{
|
{
|
||||||
if(_PaginationDebug)
|
if (breakOrNot == "Yes")
|
||||||
if (breakOrNot == "Yes")
|
{
|
||||||
Console.WriteLine("{0}", MyItemInfo.DBSequence); //,instance);
|
// DebugPagination.WriteLine("{0}", MyItemInfo.DBSequence); //,instance);
|
||||||
|
DebugPagination.WriteLine("'{0}',{1},'{2}','{3}',{4},{5},{6},{7},{8}", MyItemInfo.ShortPath, instance, message, breakOrNot,
|
||||||
|
MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize));
|
||||||
|
}
|
||||||
// Console.WriteLine("{0},{1}", MyItemInfo.DBSequence, IsFirstSubStep(MyItemInfo)); //,instance);
|
// Console.WriteLine("{0},{1}", MyItemInfo.DBSequence, IsFirstSubStep(MyItemInfo)); //,instance);
|
||||||
// Console.WriteLine("{0},'{1}','{2}',{3},{4},{5},{6},{7},'{8}'", instance, message, breakOrNot,
|
|
||||||
// MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.DBSequence);
|
|
||||||
}
|
}
|
||||||
private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize)
|
private void BuildPageBreakList(float ySpaceOnCurPage, float yPageSize)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user