- Put RO Adjustment code prior to Replace Words - Match 16 Bit

- Replaced logic for Replace Words so that they are replaced sequentially through  the text rather than sequentially through the word list.
- Added DoTransitionAdjustments that adds hardspaces to Transitions.
- Changed the NextUnicode module to ignore Hard Spaces
- Added logic to find 'real' spaces in ROs and replace only them.  Spaces are  also used to terminate RTF commands.
Added code to handle "AND Range" Transitions
- Use new ToolTip property
- Use new MyStepSectionLayoutData
- Remove Debug
Remove unused code
Renamed TwipsPerPage to PointsPerPage
Adjusted Superscript offset to match 16-Bit
- Added Debug Code to compare 16-Bit and 32-Bit text
- Added Debug Code forr Pagination
- Added optional code to match 16-Bit pagination
Added Ruler for 6 and 7 lines per inch.
This commit is contained in:
Rich
2010-09-06 19:39:44 +00:00
parent cfedc831ba
commit d739a72c7b
9 changed files with 490 additions and 70 deletions

View File

@@ -372,8 +372,8 @@ namespace Volian.Print.Library
iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter;
ItemInfo myItemInfo = section as ItemInfo;
// 792: 72 * 11 inches - TopRow - Top is high value
float _TwipsPerPage = 792;
float yTopMargin = _TwipsPerPage - (float)myItemInfo.MyDocStyle.Layout.TopRow;
float _PointsPerPage = 792;
float yTopMargin = _PointsPerPage - (float)myItemInfo.MyDocStyle.Layout.TopRow;
float yBottomMargin = yTopMargin - (float)myItemInfo.MyDocStyle.Layout.PageLength - 2 * vlnPrintObject.SixLinesPerInch;
vlnParagraph.Prefix = myItemInfo.Path;
Rtf2Pdf.PdfDebug = true;

View File

@@ -214,9 +214,11 @@ namespace Volian.Print.Library
if (visualText.Format.IsUnderline)
chk.SetUnderline(font.Color, 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); // Relative Based upon font size
if (visualText.Format.SuperScript > 0)
chk.SetTextRise(.45F * chk.Font.Size);
chk.SetTextRise(.25F * chk.Font.Size);
else if (visualText.Format.SuperScript < 0)
chk.SetTextRise(-.25F * chk.Font.Size);
else
chk.SetTextRise(0);
if (_MyFont == null)
{

View File

@@ -84,6 +84,43 @@ namespace Volian.Print.Library
base.OnEndPage(writer, document);
DrawChangeBars(writer.DirectContent);
DrawMessages(writer.DirectContent);
DrawRuler(writer.DirectContent);
}
private void DrawRuler(PdfContentByte cb)
{
if (DebugLayer == null) return;
cb.SaveState();
cb.BeginLayer(DebugLayer);
float x = (cb.PdfWriter.PageSize.Left + cb.PdfWriter.PageSize.Right) / 2;
cb.SetLineWidth(.1F);
cb.SetColorStroke(new Color(System.Drawing.Color.CornflowerBlue));
float yTop = 648;
float yBottom = 48;
cb.MoveTo(x, yTop);
cb.LineTo(x, yBottom);
int i = 0;
for (float y = yTop; y >= yBottom; y -= 12)
{
float w = 10;
if (i % 10 == 0) w = 30;
else if (i % 5 == 0) w = 20;
i++;
cb.MoveTo(x - w, y);
cb.LineTo(x, y);
}
i = 0;
for (float y = yTop; y >= yBottom; y -= 10.1F)
{
float w = 10;
if (i % 10 == 0) w = 30;
else if (i % 5 == 0) w = 20;
i++;
cb.MoveTo(x + w, y-1);
cb.LineTo(x, y-1);
}
cb.Stroke();
cb.EndLayer();
cb.RestoreState();
}
private void AddBookmarks(PdfWriter writer)
{

View File

@@ -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