|
|
|
@@ -99,6 +99,10 @@ namespace Volian.Print.Library
|
|
|
|
|
}
|
|
|
|
|
public partial class vlnParagraph : vlnPrintObject
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This variable is used to match 16 bit pagaination
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool _Match16BitPagination = false;
|
|
|
|
|
public float ParagraphToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
|
|
|
|
|
{
|
|
|
|
|
if (Processed) return yPageStart;
|
|
|
|
@@ -137,6 +141,9 @@ namespace Volian.Print.Library
|
|
|
|
|
|
|
|
|
|
private float DrawText(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation)
|
|
|
|
|
{
|
|
|
|
|
if (_TextDebug)
|
|
|
|
|
Console.WriteLine("{0},{1},'{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, FormattedText);
|
|
|
|
|
//Console.WriteLine("{0},{1},'{2}','<<END>>'", MyItemInfo.ItemID, MyItemInfo.DBSequence, IParagraph.Content);
|
|
|
|
|
float retval = yLocation;
|
|
|
|
|
if (MyItemInfo.FormatStepData.CenterOneLineOnly && MyItemInfo.MyPrevious == null && MyItemInfo.NextItem == null && Height<(1.01F*IParagraph.Leading))
|
|
|
|
|
IParagraph.Alignment = Element.ALIGN_CENTER;
|
|
|
|
@@ -147,12 +154,78 @@ namespace Volian.Print.Library
|
|
|
|
|
yPageStart = yTopMargin + YVeryTop;
|
|
|
|
|
yLocation = yPageStart - YOffset;
|
|
|
|
|
//MyItemInfo.ItemID, YSize, yPageSize, yLocation
|
|
|
|
|
Console.WriteLine("-1,'Yes','Forced Pagination',{0},{1},,{3},{4}", MyItemInfo.ItemID, YSize, 0, yLocation, MyItemInfo.DBSequence);
|
|
|
|
|
if(_PaginationDebug) Console.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);
|
|
|
|
|
}
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<string> myAttributes =new List<string>();
|
|
|
|
|
private static void AddAttribute(string attr)
|
|
|
|
|
{
|
|
|
|
|
if (myAttributes.Contains(attr))
|
|
|
|
|
return;
|
|
|
|
|
//Console.WriteLine("Attribute = \"{0}\"", attr);
|
|
|
|
|
myAttributes.Add(attr);
|
|
|
|
|
}
|
|
|
|
|
private void CheckAttributes(System.Collections.Hashtable attributes)
|
|
|
|
|
{
|
|
|
|
|
foreach (string attr in attributes.Keys)
|
|
|
|
|
{
|
|
|
|
|
AddAttribute(attr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private string FormattedText
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
bool subscript = false;
|
|
|
|
|
//if (_MyItemInfo.ItemID == 467)
|
|
|
|
|
// Console.Write("");
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
//if (IParagraph.Chunks.Count > 1)
|
|
|
|
|
// Console.WriteLine("{0} Chunks", IParagraph.Chunks.Count);
|
|
|
|
|
foreach (Chunk chk in IParagraph.Chunks)
|
|
|
|
|
{
|
|
|
|
|
string prefix = "";
|
|
|
|
|
string suffix = "";
|
|
|
|
|
CheckAttributes(chk.Attributes);
|
|
|
|
|
if (chk.Font.BaseFont != null && chk.Font.BaseFont.PostscriptFontName.ToUpper().Contains("BOLD"))
|
|
|
|
|
{
|
|
|
|
|
prefix += "\xD5";
|
|
|
|
|
suffix = "\xD6" + suffix;
|
|
|
|
|
}
|
|
|
|
|
if (chk.Attributes.ContainsKey("SUBSUPSCRIPT"))
|
|
|
|
|
{
|
|
|
|
|
float sup = (float)(chk.Attributes["SUBSUPSCRIPT"]);
|
|
|
|
|
if (sup > 0)
|
|
|
|
|
{
|
|
|
|
|
prefix += "\xA6";
|
|
|
|
|
suffix = "\xD1" + suffix;
|
|
|
|
|
}
|
|
|
|
|
else if (sup < 0)
|
|
|
|
|
{
|
|
|
|
|
prefix += "\xD1";
|
|
|
|
|
suffix = "\xA6" + suffix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (chk.Attributes.ContainsKey("UNDERLINE"))
|
|
|
|
|
{
|
|
|
|
|
prefix += "\x16";
|
|
|
|
|
suffix = "\x16" + suffix; ;
|
|
|
|
|
}
|
|
|
|
|
sb.Append(prefix + chk.Content + suffix);
|
|
|
|
|
}
|
|
|
|
|
string retval = sb.ToString();
|
|
|
|
|
retval = retval.Replace("\xD1\xA6", "");// Remove Multiple Superscript commands in a row
|
|
|
|
|
retval = retval.Replace("\xA6\xD1", "");// Remove Multiple Superscript commands in a row
|
|
|
|
|
retval = retval.Replace("\xD6\xD5", "");
|
|
|
|
|
retval = retval.Replace("\xD6\x16\xD5", "\x16");
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private bool _PaginationDebug = false;
|
|
|
|
|
private bool _TextDebug = true; // false;
|
|
|
|
|
private float DrawFigure(PdfContentByte cb, float yBottomMargin, float yLocation)
|
|
|
|
|
{
|
|
|
|
|
float retval = yLocation;
|
|
|
|
@@ -288,8 +361,11 @@ namespace Volian.Print.Library
|
|
|
|
|
ItemInfo parent = item.ActiveParent as ItemInfo;
|
|
|
|
|
//if (para.MyItemInfo.ItemID == 205)
|
|
|
|
|
// Console.Write("");
|
|
|
|
|
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,
|
|
|
|
|
if (_PaginationDebug)
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private float _YVeryTop = -1;
|
|
|
|
|
public float YVeryTop
|
|
|
|
@@ -336,6 +412,9 @@ namespace Volian.Print.Library
|
|
|
|
|
if (!MyItemInfo.IsHigh) return 0; // Don't Paginate on a Substep level
|
|
|
|
|
bool ManualPageBreak = (MyItemInfo.MyConfig as StepConfig).Step_ManualPagebreak;
|
|
|
|
|
float mySize = YSize * MyPageHelper.YMultiplier;
|
|
|
|
|
if (_Match16BitPagination) mySize = YSize;
|
|
|
|
|
float ySize7LPI = YSize + SixLinesPerInch;
|
|
|
|
|
if (_Match16BitPagination) ySize7LPI += SixLinesPerInch;
|
|
|
|
|
string firstStep = "No";
|
|
|
|
|
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null)
|
|
|
|
|
firstStep = "Yes";
|
|
|
|
@@ -352,16 +431,18 @@ namespace Volian.Print.Library
|
|
|
|
|
ShowPageBreak(5, "HLS will fit on 1 Page at 6 LPI", "Yes", YSize, yPageSize, yWithinMargins);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps && (YSize + SixLinesPerInch) < (yPageSize * SixLinesPerInch / _SevenLinesPerInch))
|
|
|
|
|
else if (MyItemInfo.ActiveFormat.MyStepSectionLayoutData.CompressSteps && (ySize7LPI) < (yPageSize * SixLinesPerInch / _SevenLinesPerInch))
|
|
|
|
|
{
|
|
|
|
|
//Console.WriteLine("'PageBreak',3,'Yes','HLS will fit on 1 Page at 7 LPI',{0},{1},{2}, {3}, {4},'{5}'", MyItemInfo.ItemID, YSize, yPageSize, yWithinMargins, (int)(100 * yWithinMargins / yPageSize), MyItemInfo.ShortPath);
|
|
|
|
|
ShowPageBreak(7, "HLS will fit on 1 Page at 7 LPI", "Yes", YSize, yPageSize, yWithinMargins);
|
|
|
|
|
//Console.WriteLine("'7LPI',{0},{1}", MyItemInfo.DBSequence, YSize);
|
|
|
|
|
return 3; // High Level Step can fit at SevenLinesPerInch
|
|
|
|
|
}
|
|
|
|
|
else // The entire step cannot fit on a blank page.
|
|
|
|
|
{
|
|
|
|
|
// if there is more than half a page left, then start to print on the current page
|
|
|
|
|
float myFirstPieceSize = GetFirstPieceSize(); //Case 0
|
|
|
|
|
if (_Match16BitPagination) myFirstPieceSize += 2 * SixLinesPerInch;
|
|
|
|
|
// TODO: Put this line back to case 0, i.e. previous line. This fixes a 16-bit vs 32-bit pagination diff in EO30 Step 20.
|
|
|
|
|
//float myFirstPieceSize = GetFirstPieceSize() + 2 * SixLinesPerInch; //Case 10 - this is to match 16bit
|
|
|
|
|
if (!ManualPageBreak && MyItemInfo.ActiveFormat.MyStepSectionLayoutData.SpecialPageBreakFlag && yWithinMargins > yPageSize / 2 &&
|
|
|
|
@@ -440,8 +521,9 @@ namespace Volian.Print.Library
|
|
|
|
|
}
|
|
|
|
|
private void ShowPageBreak(int instance, string message, string breakOrNot, float YSize, float yPageSize, float yWithinMargins)
|
|
|
|
|
{
|
|
|
|
|
if (breakOrNot == "Yes")
|
|
|
|
|
Console.WriteLine("{0}", MyItemInfo.DBSequence); //,instance);
|
|
|
|
|
if(_PaginationDebug)
|
|
|
|
|
if (breakOrNot == "Yes")
|
|
|
|
|
Console.WriteLine("{0}", MyItemInfo.DBSequence); //,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);
|
|
|
|
@@ -458,10 +540,12 @@ namespace Volian.Print.Library
|
|
|
|
|
//Console.WriteLine("'yStart',{0},{1}", MyItemInfo.DBSequence, yStart);
|
|
|
|
|
|
|
|
|
|
// The following three lines make page breaking match 16-bit:
|
|
|
|
|
//yLowerLimit = yStart - SixLinesPerInch + ySpaceOnCurPage / 2;
|
|
|
|
|
//if ((yStart + MyItemInfo.MyDocStyle.Layout.TopRow + 2 * SixLinesPerInch)>((MyItemInfo.MyDocStyle.Layout.TopRow+yPageSize-2*SixLinesPerInch)/2))
|
|
|
|
|
// yLowerLimit = yStart + 2 * SixLinesPerInch;
|
|
|
|
|
|
|
|
|
|
if (_Match16BitPagination)
|
|
|
|
|
{
|
|
|
|
|
yLowerLimit = yStart - SixLinesPerInch + ySpaceOnCurPage / 2;
|
|
|
|
|
if ((yStart + MyItemInfo.MyDocStyle.Layout.TopRow + 2 * SixLinesPerInch) > ((MyItemInfo.MyDocStyle.Layout.TopRow + yPageSize - 2 * SixLinesPerInch) / 2))
|
|
|
|
|
yLowerLimit = yStart + 2 * SixLinesPerInch;
|
|
|
|
|
}
|
|
|
|
|
// Make sure that the FirstPiece (Caution Note HLS and First Substeps) fit
|
|
|
|
|
float myFirstPieceSize = GetFirstPieceSize(); //Case 0
|
|
|
|
|
if (myFirstPieceSize < ySpaceOnCurPage) yLowerLimit = Math.Max(myFirstPieceSize + yStart, yLowerLimit);
|
|
|
|
@@ -475,6 +559,7 @@ namespace Volian.Print.Library
|
|
|
|
|
MyPageHelper.ParaBreaks.Add(paraBreak);
|
|
|
|
|
ySpaceOnCurPage = yPageSize - 2 * SixLinesPerInch; // Allow for continue message and blank line.
|
|
|
|
|
yLowerLimit = ySpaceOnCurPage / 2;
|
|
|
|
|
if(_Match16BitPagination)yLowerLimit -= 1.5F * SixLinesPerInch; // 276 for HLP
|
|
|
|
|
yStart = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -541,7 +626,7 @@ namespace Volian.Print.Library
|
|
|
|
|
{
|
|
|
|
|
//ItemInfo prev = myList[stepLevel][yLocation].MyItemInfo.MyPrevious;
|
|
|
|
|
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 5609) Console.WriteLine("aer");
|
|
|
|
|
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 5613) Console.WriteLine("rno");
|
|
|
|
|
//if (myList[stepLevel][yLocation].MyItemInfo.ItemID == 4312) Console.WriteLine("rno");
|
|
|
|
|
// The top of this step is more than 1/2 way down the page
|
|
|
|
|
if ((-yLocation + yStart) >= yLowerLimit)
|
|
|
|
|
{
|
|
|
|
@@ -595,7 +680,7 @@ namespace Volian.Print.Library
|
|
|
|
|
MyTopRNO = this;
|
|
|
|
|
else
|
|
|
|
|
MyTopRNO = MyParent.MyTopRNO;
|
|
|
|
|
MyTopRNO.LastRNO = this;
|
|
|
|
|
if(MyTopRNO != null) MyTopRNO.LastRNO = this;
|
|
|
|
|
}
|
|
|
|
|
MyContentByte = cb;
|
|
|
|
|
MyPageHelper.MyParagraphs.Add(itemInfo.ItemID, this);
|
|
|
|
@@ -749,8 +834,6 @@ namespace Volian.Print.Library
|
|
|
|
|
private string cbMess = null;
|
|
|
|
|
private vlnChangeBar DoChangeBar(PdfContentByte cb, ItemInfo itemInfo, VlnSvgPageHelper myPageHelper, float xoff, float yoff, int maxRNO, FormatInfo formatInfo) //, vlnChangeBar myCB)
|
|
|
|
|
{
|
|
|
|
|
if (myPageHelper.ChangeBarDefinition.MyChangeBarType == PrintChangeBar.Without) return null;
|
|
|
|
|
|
|
|
|
|
// find column for the change bar based on format flags - this is code from 16-bit
|
|
|
|
|
// if AbsoluteFixedChangeColumn
|
|
|
|
|
// if FixedAERChangeColumn
|
|
|
|
|