diff --git a/PROMS/Volian.Print.Library/vlnBox.cs b/PROMS/Volian.Print.Library/vlnBox.cs index 96dcea15..ae97ca44 100644 --- a/PROMS/Volian.Print.Library/vlnBox.cs +++ b/PROMS/Volian.Print.Library/vlnBox.cs @@ -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) { - // 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) - top = CalculateYOffset(yPageStart, yTopMargin); - // Bug fix B2013-091 - // added YMultiplier to handle compress pages - // bottom row of asterisks was in non-compressed line location + // 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) + top = CalculateYOffset(yPageStart, yTopMargin); + // 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); // 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); - + // 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)); + float bxHorzTextWidth = GetTextWidth(vf, MyBox.BXHorz); // get the width of the BXHorz string // Do the top line first: - StringBuilder sb = new StringBuilder(); - sb.Append(MyBox.BXULC); - float size = (float)(MyBox.BXULC.Length * (72/vf.CPI)); + StringBuilder sb = new StringBuilder(); + sb.Append(MyBox.BXULC); + float size = GetTextWidth(vf,MyBox.BXULC); //(float)(MyBox.BXULC.Length * (72 / vf.CPI)); string bxstr = null; if (!ContainsPageBreak) // Only do top line if there is no page break. { while (size < endHorz) - { - sb.Append(MyBox.BXHorz); - size = size + (float)(MyBox.BXHorz.Length * (72/vf.CPI)); - } + { + sb.Append(MyBox.BXHorz); + 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 // 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. + size = size + GetTextWidth(vf, MyBox.BXURC);//(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); } // 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)); + sb.Remove(0, sb.Length); + sb.Append(MyBox.BXLLC); + size = GetTextWidth(vf, MyBox.BXLLC); //(float)(MyBox.BXLLC.Length * (72 / vf.CPI)); while (size < endHorz) - { - sb.Append(MyBox.BXHorz); - size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI)); - } - bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC; - size = size + (float)((MyBox.BXLRC.Length) * (72/vf.CPI)); - Rtf = GetRtf(bxstr, vf); + { + sb.Append(MyBox.BXHorz); + size = size + bxHorzTextWidth;//(float)(MyBox.BXHorz.Length * (72 / vf.CPI)); + } + bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC; + size = size + GetTextWidth(vf, MyBox.BXLRC); //(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 + 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) { // set the top & bottom of sides. If there is a page break in the middle of box, adjust these. diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index 10b8fa32..727e6ab9 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -63,7 +63,6 @@ namespace Volian.Print.Library foreach (ItemInfo iChildItemInfo in itemInfoList) { ItemInfo childItemInfo = iChildItemInfo; - // 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. // 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)) yoff += ln * vlnPrintObject.SixLinesPerInch; } + bxIndex = bxIndx; } else // Change Box Style {