diff --git a/PROMS/Volian.Print.Library/Grid2Pdf.cs b/PROMS/Volian.Print.Library/Grid2Pdf.cs index a5fb8fc2..b79e3618 100644 --- a/PROMS/Volian.Print.Library/Grid2Pdf.cs +++ b/PROMS/Volian.Print.Library/Grid2Pdf.cs @@ -424,7 +424,6 @@ namespace Volian.Print.Library if (!ii.FormatStepData.Font.FontIsProportional()) ff = Volian.Svg.Library.VolianPdf.GetFont("VESymbFix", (int)ii.FormatStepData.Font.Size, (int)ii.FormatStepData.Font.WindowsFont.Style); iTextSharp.text.Paragraph myPara = RtfToParagraph(str, ff, r, c); - myColumnText1.SetSimpleColumn(0, 0, w-2, MyContentByte.PdfDocument.PageSize.Top); // Padding = 4 if (str.Contains(@"\'05")) { @@ -450,26 +449,9 @@ namespace Volian.Print.Library myPara.IndentationLeft = li; myPara.FirstLineIndent = fi; } - // RHM 20120925 - Line spacing should be 6 lines per inch. In order to get a valid value - // for TotalLeading you have to set MultipliedLeading first: - myPara.MultipliedLeading = 1.0f; - // once there is valid value for TotalLeading (from previous line), you can use it to - // calculate a MultipliedLeading to give 6 LPI (12 points) - myPara.MultipliedLeading = 12.0f / myPara.TotalLeading; - float bfs = BiggestFontSize(myPara); - float sfs = SmallestFontSize(myPara); - // B2017-233, B2017-234 MultipliedLeading affects the vertical positon of the text in the table cell. When some characters in the table are either bigger or smaller - // than the font size defined in the plant's format, we need to adjust or recalulate the MultipliedLeading value. - // If the smallest font size is less that 10 then set the MultipliedLeading to 1 (need for AEP tables that use a smaller bullet character) - // if the the biggest font size is greater than 12 then we to calulate a new MultipliedLeading value base on BiggestFontSize - // The ogrinal fix(for B2017-105) was for Wolf Creek, but old logic broke for IP2/IP3, Calvert, Ginna, All Duke plants, and Commanche Peak - if (sfs < 10f) myPara.MultipliedLeading = 1f; - if (bfs > 12f) - { - //Console.WriteLine("multipliedLeading {0} bfs {1} sfs {2}", myPara.MultipliedLeading, bfs, sfs); - myPara.MultipliedLeading = 12f / bfs; // B2017-105, when box symbol size was increased, alignment in tables was off - //Console.WriteLine("multipliedLeading {0}", myPara.MultipliedLeading); - } + // RHM 20120925 - Line spacing should be 6 lines per inch. + // B2018-003 Change code to use absolute Leading rather than Multiplied based on Font size + myPara.SetLeading(12F, 0); myPara.SpacingAfter = 8; // RHM 20120925 - Add a line to properly space text from lines. if(Rtf2Pdf.GetTableScrunchingStatus(TableScrunching.Phase2)) // RHM20150429 - Table Scrunch myPara.SpacingAfter = 0;// YAdjust_SpacingAfter; // RHM 20120925 - Add a line to properly space text from lines. @@ -485,7 +467,7 @@ namespace Volian.Print.Library float hContent = 4 + posBefore - posAfter; if (Rtf2Pdf.GetTableScrunchingStatus(TableScrunching.Phase4))// RHM20150525 - Table Scrunc { - hContent = 0 + posBefore - posAfter;//YAdjust_HContent + posBefore - posAfter; + hContent = 0 + posBefore - posAfter;//YAdjust_HContent + posBefore - posAfter; // if (myPara.Chunks.Count > 0 && myPara.Chunks[myPara.Chunks.Count - 1] == "\n") // hContent -= 12; } @@ -501,7 +483,8 @@ namespace Volian.Print.Library // hMax = Math.Max(hMax, hContent - (cr.r2 - cr.r1) * _SixLinesPerInch); if (hContent > h) { // RHM20150429 - Table Scrunch - //if (ShowDetails) Console.WriteLine("Less {0},{1},{2},{3},{4},{5}", r, c, posBefore, posAfter, hContent, hMax); + // B2018-003 modified debug to add h + //if (ShowDetails) Console.WriteLine("Less {0},{1},{2},{3},{4},{5},{6}", r, c, posBefore, posAfter, h, hContent, hMax); MyTable.AdjustRowTop(cr.r1, cr.r2, hContent); } // RHM20150429 - Table Scrunch if (Rtf2Pdf.GetTableScrunchingStatus(TableScrunching.Phase5)) @@ -832,7 +815,7 @@ namespace Volian.Print.Library Rtf2iTextSharp rtf2IText = new Rtf2iTextSharp(rtfDoc); rtf2IText.DefaultFont = mySymFont; iTextSharp.text.Paragraph para = rtf2IText.Convert(); - para.SetLeading(_SixLinesPerInch, 0); + para.SetLeading(_SixLinesPerInch , 0); return para; } // The text font used in FixRTFToPrint for grid @@ -1266,6 +1249,44 @@ namespace Volian.Print.Library { return string.Format("{0}:{1}", r1, c1); } + // B2018-003 - RHM 20180319 Add + public void PdfDebug(iTextSharp.text.pdf.ColumnText myColumnText, float x, float bottom, float right, float y, string debugText, float yDescent) + { + PdfContentByte cb = myColumnText.Canvas; + VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; + PdfLayer debugLayer = _MyPageHelper == null ? null : _MyPageHelper.DebugLayer; + if (debugLayer == null) return; + System.Drawing.Color sysColor = PrintOverride.OverrideDebugColor(System.Drawing.Color.Gray); + cb.SaveState(); + cb.BeginLayer(debugLayer); + cb.SetColorStroke(new Color(sysColor)); + cb.SetLineWidth(.1F); + cb.MoveTo(x, y - yDescent); + cb.LineTo(right, y - yDescent); + cb.LineTo(right, bottom - yDescent); + cb.LineTo(x, bottom - yDescent); + cb.LineTo(x, y - yDescent); + for (float yy = y - MyPara.TotalLeading; yy > bottom; yy -= MyPara.TotalLeading) + { + cb.MoveTo(x, yy - yDescent); + cb.LineTo(right, yy - yDescent); + } + cb.Stroke(); + if (debugText != "") + { + ColumnText ct = new ColumnText(cb); + ct.SetSimpleColumn(x, y - yDescent, right, y - yDescent - 50); + iTextSharp.text.Font font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 2); + Chunk chk = new Chunk(debugText + string.Format(", Top = {0}", y), font); + Phrase ph = new Phrase(chk); + ct.AddElement(ph); + cb.SetColorFill(new Color(sysColor)); + ct.Go(); + } + cb.EndLayer(); + cb.RestoreState(); + } + //RHM 20180319 End of Add public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top) { myColumnText.Canvas.SaveState(); @@ -1289,7 +1310,9 @@ namespace Volian.Print.Library adjustTextLocation = mult * 0; if (mult != 1F) adjustTextLocation=1; } - myColumnText1.SetSimpleColumn(1 + left + x, top - y - h , left + x + w - 2, 1 + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding + myColumnText1.SetSimpleColumn(1 + left + x, top - y - h, left + x + w - 2, 1 + top - y - hAdjust - adjustTextLocation); // 2 == Default Padding + // B2018-003 - RHM 20180319 Change Debug Output + string dbg = string.Format("Row={0}, Col={1}, Leading={2}, SpacingBefore={3}", r1, c1, MyPara.TotalLeading, MyPara.SpacingBefore); // B2018-033 VCS SAG-6 Steps 3 and 9 and SACRG1 Step 13 // Added Header to debug output if (ShowDetails) @@ -1308,7 +1331,8 @@ namespace Volian.Print.Library string ctai = Rtf2Pdf.ChunkTextAttributesInfo(chk1); Volian.Base.Library.BaselineMetaFile.WriteLine("\t{0},{1},{2},{3},\"{4}\"", chk1.Font.Familyname, chk1.Font.Size, chk1.Font.Style, ctai, Rtf2Pdf.FixText(chk1.Content)); } - MyPara.MultipliedLeading *= _MyPageHelper.YMultiplier; + // B2018-003 - Adjust Leading for 7LPI if necessary + MyPara.SetLeading(MyPara.TotalLeading * _MyPageHelper.YMultiplier, 0); vlnCells.FixHyphens(MyPara, MyTable); vlnCells.FixBackslashes(MyPara, MyTable); myColumnText1.AddElement(MyPara); @@ -1329,7 +1353,10 @@ namespace Volian.Print.Library // B2018-033 Removed debug printout //if(ShowDetails)Console.WriteLine("ToPDF posBefore,posAfter,difference={0},{1},{2},{3}", // posBefore, posAfter, posBefore - posAfter,w); - myColumnText.Canvas.RestoreState(); + // B2018-003 Calculate hh + float hh = posBefore - posAfter; + PdfDebug(myColumnText1, 1 + left + x, top - y - hh - hAdjust, left + x + w - 2, 3 + top - y - hAdjust - adjustTextLocation, dbg, MyPara.TotalLeading / 5); + myColumnText.Canvas.RestoreState(); } // B2018-033 VCS SAG-6 Steps 3 and 9 and SACRG1 Step 13 // Added Header to debug output