From 00f53b54694f9871118b8d0d77dd4e42c2a338a5 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 19 Feb 2021 19:26:31 +0000 Subject: [PATCH] C2021-005 code to adjust the starting vertical position of table cell text when the font size changes --- PROMS/Volian.Print.Library/Grid2Pdf.cs | 57 ++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/PROMS/Volian.Print.Library/Grid2Pdf.cs b/PROMS/Volian.Print.Library/Grid2Pdf.cs index e5917868..13762eab 100644 --- a/PROMS/Volian.Print.Library/Grid2Pdf.cs +++ b/PROMS/Volian.Print.Library/Grid2Pdf.cs @@ -343,7 +343,7 @@ public string Path public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top) { //ZoomGrid(myColumnText, left, top); - if(ShowDetails) Console.WriteLine("vvvvvvToPdf============{0}===============", ItemID);// RHM20150525 - Table Scrunc + if (ShowDetails) Console.WriteLine("vvvvvvToPdf============{0}===============", ItemID);// RHM20150525 - Table Scrunc ShowRowTops("ToPDF1"); PdfContentByte cb = myColumnText.Canvas; // RHM20150429 - Table Scrunch VlnSvgPageHelper myPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; @@ -498,6 +498,10 @@ public string Path TrimNewlines(myPara); // RHM20150429 - Table Scrunch myColumnText1.AddElement(myPara); //myColumnText1.Canvas.SetColorFill(PrintOverride.OverrideTextColor(System.Drawing.Color.Black)); + + // PIP TEST CODE FOR TABLE SHADING + //myColumnText1.Canvas.SetColorFill(new iTextSharp.text.Color(System.Drawing.Color.Red)); + float posBefore = myColumnText1.YLine; int status = myColumnText1.Go(true); float posAfter = myColumnText1.YLine; @@ -1018,6 +1022,20 @@ public string Path private static float _SixLinesPerInch = 12; // twips #endregion #region Public Methods + // C2021-005 Get the largest font size being used. + // - only need for the first line of table cell text + private float GetLargestFontSize(vlnCell vc) + { + float largestFontSize = 12; + foreach (Chunk ck in vc.MyPara) + { + if (ck.Content.EndsWith("\n")) + break; // end of first line + if (ck.ToString().Trim().Length > 0) + largestFontSize = Math.Max(largestFontSize, ck.Font.Size); + } + return largestFontSize; + } public void ToPdf(iTextSharp.text.pdf.ColumnText myColumnText, float left, float top) { foreach (vlnCell myCell in this) @@ -1026,12 +1044,18 @@ public string Path // B2020-082 - AEP Production - American Electric Power - D. C. Cook // / Current (Post FLEX) - U1 NOP NOT [EOPs] - ES-3.3.SProcedure Body.S9..S1..S1..T1. // Table did not print properly. Cell text was truncated. + float largestFontSize = GetLargestFontSize(myCell); // C2021-005 get the largest font size for the cell text int topPlacementAdjust = (myCell.MyPara.Font.Size == 12 && myCell.MyPara.Font.Familyname != "Courier New" && myCell.MyPara.Font.Familyname != "VESymbFix") ? 1 : 3; // for font size of 12 set to one, else set to 3 - // B2020-140 for Wolf Creek check boxes in tables were printing too hight in the table cells - added format variable to overide topPlacementAdjust - if (myCell.MyPara !=null && ItemInfo.Get(myCell.MyTable.ItemID).ActiveFormat.MyStepSectionLayoutData.OverrideTableTopIndent != null) - topPlacementAdjust = (int)ItemInfo.Get(myCell.MyTable.ItemID).ActiveFormat.MyStepSectionLayoutData.OverrideTableTopIndent; + if (largestFontSize != 12) // C2021-005 adjust the text positon based on the font size change + topPlacementAdjust -= (int)(largestFontSize - 12); // C2021-005 adjust placement based on font size change + // B2020-140 for Wolf Creek check boxes in tables were printing too high in the table cells - added format variable to overide topPlacementAdjust + if (myCell.MyPara != null && ItemInfo.Get(myCell.MyTable.ItemID).ActiveFormat.MyStepSectionLayoutData.OverrideTableTopIndent != null) + { + if (largestFontSize > 18) // C2021-005 Only need when cell text has the empty box symbol which WCN format override the size to 20pts + topPlacementAdjust = (int)ItemInfo.Get(myCell.MyTable.ItemID).ActiveFormat.MyStepSectionLayoutData.OverrideTableTopIndent; + } myCell.ToPdf(myColumnText, left, top, topPlacementAdjust); } } @@ -1578,6 +1602,9 @@ public string Path float yTop = top - y + YOffset; float xRight = left + x + w + XOffset; float yBottom = top - y - h + YOffset; + // PIP TESTING SHADING CELLS + //FillRectangle(cb, xLeft, xRight, yTop-2, yBottom, Color.GREEN, Color.MAGENTA); + // ZoomToCell(myColumnText, xLeft, yTop, xRight, yBottom); // Draw Top Side for the first row if (r1 == 0) @@ -1590,7 +1617,29 @@ public string Path // Draw Right Side DrawLineVertical(cb, "Right", xRight, yBottom, yTop, RightSide, RightOfBottomSide, BottomSide, BelowRightSide, TopSide, RightOfTopSide, AboveRightSide); cb.RestoreState(); + + // PIP TESTING SHADING CELLS + //FillRectangle(cb, xLeft, xRight, yTop, yBottom, Color.GREEN, Color.MAGENTA); } + + // PIP TESTING SHADING CELLS + private void FillRectangle(PdfContentByte cb, float xLeft, float xRight, float yTop, float yBottom, Color FillColor, Color OutlineColor) + { + cb.SaveState(); + //bool fill = FillColor != System.Drawing.Color.Transparent; + //bool stroke = OutlineWidth.Value != 0F && OutlineColor != System.Drawing.Color.Empty; + //if (fill) + cb.SetColorFill(FillColor); + //if (stroke) + //{ + cb.SetLineWidth(.5f);//scale.M(OutlineWidth)); + cb.SetColorStroke(OutlineColor); + //} + cb.RoundRectangle(xLeft, yBottom, xRight-xLeft, yTop-yBottom, .005F); + cb.Fill();//.FillStroke(); + cb.RestoreState(); + } + private void DrawHorizontalLine(PdfContentByte cb, string side, float xStart, float xEnd, float y, GridLinePattern LinePattern, GridLinePattern startToLeft, GridLinePattern startToRight, GridLinePattern startAhead, GridLinePattern endToLeft, GridLinePattern endToRight, GridLinePattern endAhead)