Fixed logic to account for font when building the row of asterisks above and below Cautions.
Fixed the position of the Caution when it is after a Note
This commit is contained in:
parent
30facbbec0
commit
83415355ae
@ -153,62 +153,94 @@ namespace Volian.Print.Library
|
|||||||
|
|
||||||
private void DrawAsteriskTopBottom(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left)
|
private void DrawAsteriskTopBottom(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left)
|
||||||
{
|
{
|
||||||
// this box is not drawn, it is a series of asterisks drawn above and below text.
|
// this box is not drawn, it is a series of asterisks drawn above and below text.
|
||||||
// For this box, there are no vertical edges (RGE uses this box type)
|
// For this box, there are no vertical edges (RGE uses this box type)
|
||||||
top = CalculateYOffset(yPageStart, yTopMargin);
|
top = CalculateYOffset(yPageStart, yTopMargin);
|
||||||
// Bug fix B2013-091
|
// Bug fix B2013-091
|
||||||
// added YMultiplier to handle compress pages
|
// added YMultiplier to handle compress pages
|
||||||
// bottom row of asterisks was in non-compressed line location
|
// bottom row of asterisks was in non-compressed line location
|
||||||
bottom = top - (Height * MyPageHelper.YMultiplier);
|
bottom = top - (Height * MyPageHelper.YMultiplier);
|
||||||
|
|
||||||
// create a new font without any styles such as underline.
|
// 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);
|
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);
|
||||||
|
|
||||||
// To find the length of the line, account for the length of the upper right corner also (BXURC)
|
// 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;
|
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));
|
float endHorz = (float)MyBox.End - (float)MyBox.Start - (float)(urcLen * (72 / vf.CPI));
|
||||||
|
|
||||||
|
float bxHorzTextWidth = GetTextWidth(vf, MyBox.BXHorz); // get the width of the BXHorz string
|
||||||
// Do the top line first:
|
// Do the top line first:
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.Append(MyBox.BXULC);
|
sb.Append(MyBox.BXULC);
|
||||||
float size = (float)(MyBox.BXULC.Length * (72/vf.CPI));
|
float size = GetTextWidth(vf,MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI));
|
||||||
string bxstr = null;
|
string bxstr = null;
|
||||||
if (!ContainsPageBreak) // Only do top line if there is no page break.
|
if (!ContainsPageBreak) // Only do top line if there is no page break.
|
||||||
{
|
{
|
||||||
while (size < endHorz)
|
while (size < endHorz)
|
||||||
{
|
{
|
||||||
sb.Append(MyBox.BXHorz);
|
sb.Append(MyBox.BXHorz);
|
||||||
size = size + (float)(MyBox.BXHorz.Length * (72/vf.CPI));
|
size = size + bxHorzTextWidth; //(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
|
||||||
}
|
}
|
||||||
// Tack on the right upper corner. For some formats, the upper right corner in the
|
// 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
|
// 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:
|
// end of the string, so remove the space before tacking on the upper right corner:
|
||||||
bxstr = sb.ToString();
|
bxstr = sb.ToString();
|
||||||
if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd();
|
if (bxstr[bxstr.Length - 1] == ' ' && MyBox.BXURC[0] == ' ') bxstr = bxstr.TrimEnd();
|
||||||
bxstr = bxstr + MyBox.BXURC;
|
bxstr = bxstr + MyBox.BXURC;
|
||||||
size = size + (float)((MyBox.BXURC.Length) * (72/vf.CPI));
|
size = size + GetTextWidth(vf, MyBox.BXURC);//(float)((MyBox.BXURC.Length) * (72 / vf.CPI));
|
||||||
Rtf = GetRtf(bxstr, vf);
|
Rtf = GetRtf(bxstr, vf);
|
||||||
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
|
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
|
||||||
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin);
|
Rtf2Pdf.TextAt(cb, IParagraph, left, top, size + 10, 100, "", yBottomMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the bottom line now:
|
// Handle the bottom line now:
|
||||||
if (bottom < yBottomMargin) return; // Box goes off page, i.e. page break, don't do bottom
|
if (bottom < yBottomMargin) return; // Box goes off page, i.e. page break, don't do bottom
|
||||||
|
|
||||||
sb.Remove(0, sb.Length);
|
sb.Remove(0, sb.Length);
|
||||||
sb.Append(MyBox.BXLLC);
|
sb.Append(MyBox.BXLLC);
|
||||||
size = (float)(MyBox.BXLLC.Length * (72 / vf.CPI));
|
size = GetTextWidth(vf, MyBox.BXLLC); //(float)(MyBox.BXLLC.Length * (72 / vf.CPI));
|
||||||
while (size < endHorz)
|
while (size < endHorz)
|
||||||
{
|
{
|
||||||
sb.Append(MyBox.BXHorz);
|
sb.Append(MyBox.BXHorz);
|
||||||
size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI));
|
size = size + bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI));
|
||||||
}
|
}
|
||||||
bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC;
|
bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC;
|
||||||
size = size + (float)((MyBox.BXLRC.Length) * (72/vf.CPI));
|
size = size + GetTextWidth(vf, MyBox.BXLRC); //(float)((MyBox.BXLRC.Length) * (72 / vf.CPI));
|
||||||
Rtf = GetRtf(bxstr, vf);
|
Rtf = GetRtf(bxstr, vf);
|
||||||
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
|
IParagraph = null; // set to null so that next access of IParagraph sets the Rtf.
|
||||||
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin);
|
Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size + 10, 100, "", yBottomMargin);
|
||||||
}
|
}
|
||||||
|
private string symblsStr = "\u25CF\u0394"; // string of possible symbol character in a tab
|
||||||
|
// add symbol characters as needed
|
||||||
|
// "\u25CF" - solid bullet
|
||||||
|
// \x0394 - delta
|
||||||
|
|
||||||
|
private System.Drawing.FontStyle GetSysFontStyle(VE_Font f)
|
||||||
|
{
|
||||||
|
if (f.Style == E_Style.Italics)
|
||||||
|
return System.Drawing.FontStyle.Italic;
|
||||||
|
return FontStyle.Regular;
|
||||||
|
}
|
||||||
|
private float GetTextWidth(VE_Font vefont, string txt)
|
||||||
|
{
|
||||||
|
string symblFontName = (vefont.FontIsProportional()) ? "Arial Unicode MS" : "VESymbFix";
|
||||||
|
System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size, GetSysFontStyle(vefont));
|
||||||
|
System.Drawing.Font symbFont = new System.Drawing.Font(symblFontName, (float)vefont.Size);
|
||||||
|
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
|
||||||
|
iTextSharp.text.Font iSymblFont = Volian.Svg.Library.VolianPdf.GetFont(symbFont);
|
||||||
|
float w = 0;
|
||||||
|
foreach (char c in txt)
|
||||||
|
{
|
||||||
|
int idx = symblsStr.IndexOf(c);
|
||||||
|
if (idx >= 0) // symbol character - use symbol font to find its width
|
||||||
|
w += iSymblFont.BaseFont.GetWidthPointKerned(symblsStr[idx].ToString(), (float)vefont.Size);
|
||||||
|
else
|
||||||
|
w += iFont.BaseFont.GetWidthPointKerned(c.ToString(), (float)vefont.Size);
|
||||||
|
}
|
||||||
|
//float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right)
|
private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right)
|
||||||
{
|
{
|
||||||
// set the top & bottom of sides. If there is a page break in the middle of box, adjust these.
|
// set the top & bottom of sides. If there is a page break in the middle of box, adjust these.
|
||||||
|
@ -63,7 +63,6 @@ namespace Volian.Print.Library
|
|||||||
foreach (ItemInfo iChildItemInfo in itemInfoList)
|
foreach (ItemInfo iChildItemInfo in itemInfoList)
|
||||||
{
|
{
|
||||||
ItemInfo childItemInfo = iChildItemInfo;
|
ItemInfo childItemInfo = iChildItemInfo;
|
||||||
|
|
||||||
// if in a ComponentTableFormat (FNP sub format 1, component list), column headers are defined
|
// if in a ComponentTableFormat (FNP sub format 1, component list), column headers are defined
|
||||||
// by the first level of children. The data for the column is the child of the column header.
|
// by the first level of children. The data for the column is the child of the column header.
|
||||||
// Sometimes the column will not have data, the following handles that case. Also, use
|
// Sometimes the column will not have data, the following handles that case. Also, use
|
||||||
@ -131,6 +130,7 @@ namespace Volian.Print.Library
|
|||||||
if (!boxHLS || (boxHLS && !childItemInfo.HasCautionOrNote))
|
if (!boxHLS || (boxHLS && !childItemInfo.HasCautionOrNote))
|
||||||
yoff += ln * vlnPrintObject.SixLinesPerInch;
|
yoff += ln * vlnPrintObject.SixLinesPerInch;
|
||||||
}
|
}
|
||||||
|
bxIndex = bxIndx;
|
||||||
}
|
}
|
||||||
else // Change Box Style
|
else // Change Box Style
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user