This commit is contained in:
@@ -30,6 +30,14 @@ namespace Volian.Print.Library
|
||||
// no 'Box' was defined in format file.
|
||||
public string DefBox = null;
|
||||
public float DefEnd = 0;
|
||||
|
||||
private bool _ContainsPageBreak = false;
|
||||
public bool ContainsPageBreak
|
||||
{
|
||||
get { return _ContainsPageBreak; }
|
||||
set { _ContainsPageBreak = value; }
|
||||
}
|
||||
//private bool _DoBottom = true;
|
||||
public vlnBox()
|
||||
{
|
||||
}
|
||||
@@ -43,8 +51,7 @@ namespace Volian.Print.Library
|
||||
const string BoxFPLCaution = "\x2588.\x2580.\x2588.\x2588. . .\x2588.\x2588. .\x2584. . ";
|
||||
const string BoxAsterisk = " *.* .* . . . . *.* . .* . . ";
|
||||
const string BoxAsteriskWithSides1 = " *.* .* .* . . . *.* . .* . . "; // ip2
|
||||
const string BoxAsteriskWithSides2 = "*. *.*.*. . .*.*. . *. . "; // ip3 (sub 15)
|
||||
|
||||
const string BoxAsteriskWithSides2 = " *. *.*.*. . . *.*. . *. . "; // ip3
|
||||
public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin)
|
||||
{
|
||||
if (MyBox == null) return yPageStart;
|
||||
@@ -137,35 +144,46 @@ namespace Volian.Print.Library
|
||||
// Bug fix B2013-091
|
||||
// added YMultiplier to handle compress pages
|
||||
// bottom row of asterisks was in non-compressed line location
|
||||
bottom = top - (Height * MyPageHelper.YMultiplier);//Height;
|
||||
bottom = top - (Height * MyPageHelper.YMultiplier);
|
||||
|
||||
// create a new font without any styles such as underline.
|
||||
VE_Font vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, E_Style.None, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
|
||||
|
||||
// Top line first:
|
||||
// To find the length of the line, account for the length of the upper right corner also (BXURC)
|
||||
int urcLen = MyBox.BXHorz[MyBox.BXHorz.Length - 1] == ' ' && MyBox.BXURC[0] == ' ' ? 1 : MyBox.BXURC.Length;
|
||||
float endHorz = (float)MyBox.End - (float)MyBox.Start - (float)(urcLen * (72 / vf.CPI));
|
||||
|
||||
// Do the top line first:
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(MyBox.BXULC);
|
||||
float size = (float)(MyBox.BXULC.Length * (72 / vf.CPI));
|
||||
while (size < (MyBox.End - MyBox.Start))
|
||||
string bxstr = null;
|
||||
if (!ContainsPageBreak) // Only do top line if there is no page break.
|
||||
{
|
||||
sb.Append(MyBox.BXHorz);
|
||||
size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI));
|
||||
while (size < endHorz)
|
||||
{
|
||||
sb.Append(MyBox.BXHorz);
|
||||
size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI));
|
||||
}
|
||||
// Tack on the right upper corner. For some formats, the upper right corner in the
|
||||
// had the first character as a space, this would put two spaces in a row at the
|
||||
// end of the string, so remove the space before tacking on the upper right corner:
|
||||
bxstr = sb.ToString();
|
||||
if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd();
|
||||
bxstr = bxstr + MyBox.BXURC;
|
||||
size = size + (float)((MyBox.BXURC.Length) * (72 / vf.CPI));
|
||||
Rtf = GetRtf(bxstr, vf);
|
||||
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
|
||||
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin);
|
||||
}
|
||||
// Tack on the right upper corner. For some reason, the upper right corner in the
|
||||
// formats had the first character as a space, this would put two spaces in a row
|
||||
// at the end of the string, so remove the space before tacking on the upper right
|
||||
// corner:
|
||||
string bxstr = sb.ToString().TrimEnd() + MyBox.BXURC;
|
||||
size = size + (float)((MyBox.BXURC.Length) * (72 / vf.CPI));
|
||||
Rtf = GetRtf(bxstr, vf);
|
||||
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
|
||||
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size, 100, "", yBottomMargin);
|
||||
|
||||
// Bottom line now
|
||||
// Handle the bottom line now:
|
||||
if (bottom < yBottomMargin) return; // Box goes off page, i.e. page break, don't do bottom
|
||||
|
||||
sb.Remove(0, sb.Length);
|
||||
sb.Append(MyBox.BXLLC);
|
||||
size = (float)(MyBox.BXLLC.Length * (72 / vf.CPI));
|
||||
while (size < (MyBox.End-MyBox.Start))
|
||||
while (size < endHorz)
|
||||
{
|
||||
sb.Append(MyBox.BXHorz);
|
||||
size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI));
|
||||
@@ -174,14 +192,31 @@ namespace Volian.Print.Library
|
||||
size = size + (float)((MyBox.BXLRC.Length) * (72 / vf.CPI));
|
||||
Rtf = GetRtf(bxstr, vf);
|
||||
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
|
||||
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size, 100, "", yBottomMargin);
|
||||
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin);
|
||||
}
|
||||
private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right)
|
||||
{
|
||||
top = CalculateYOffset(yPageStart, yTopMargin);
|
||||
bottom = top - (Height * MyPageHelper.YMultiplier);
|
||||
// set the top & bottom of sides. If there is a page break in the middle of box, adjust these.
|
||||
// The vlnBox property, ContainsPageBreak, flags that a break occurred.
|
||||
if (!ContainsPageBreak) // if no page break, just use top as is.
|
||||
{
|
||||
top = CalculateYOffset(yPageStart, yTopMargin);
|
||||
bottom = top - (Height * MyPageHelper.YMultiplier);
|
||||
}
|
||||
else
|
||||
{
|
||||
// to calculate the bottom, don't adjust the top yet.
|
||||
top = CalculateYOffset(yPageStart, yTopMargin);
|
||||
bottom = top - (Height * MyPageHelper.YMultiplier);
|
||||
top = yTopMargin; // reset top to top margin since there was a page break.
|
||||
}
|
||||
|
||||
// Check that the bottom is within the bottom margin, if this step spans more than one page,
|
||||
// stop the side asterisks at the bottom margin. (pagination puts inserts a page break here)
|
||||
if (bottom < yBottomMargin) bottom = yBottomMargin;
|
||||
|
||||
float height = (SixLinesPerInch * MyPageHelper.YMultiplier) + 4; // just add a little on so that height is a little bigger than character
|
||||
VE_Font vf = MyParent.MyItemInfo.FormatStepData.Font;
|
||||
VE_Font vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, E_Style.None, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI);
|
||||
|
||||
// Left side first:
|
||||
Rtf = GetRtf(MyBox.BXVert, vf);
|
||||
|
Reference in New Issue
Block a user