From cbf44eb6895cb650da8101ab3498d6137f847f1f Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 31 May 2017 13:48:07 +0000 Subject: [PATCH] B2017-098 Adjust font size in Tables within Supplemantal Information --- PROMS/Volian.Print.Library/PromsPrinter.cs | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 4c3c30fb..4c468b0e 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -1838,6 +1838,7 @@ namespace Volian.Print.Library private void ReduceSupInfoGroupFontSize(vlnParagraph pg, float scaler, PdfContentByte cb) { float hBefore = pg.Height;// Save initial paragraph height + AdjustSupInfoTable(pg, scaler,cb); NewSupInfoFixChunks(pg,scaler);// Apply multiplier to font size pg.IParagraph.Leading = scaler * pg.IParagraph.Leading; // Adjust leading (line spacing) float hAfter = pg.GetParagraphHeight(cb, pg.IParagraph, "", pg.Width); // Calculate new paragraph height @@ -1872,6 +1873,45 @@ namespace Volian.Print.Library NewSupInfoFixParts(po, scaler); } /// + /// Adjust the Table Fonts to shrink the sup info text + /// + /// vlnParagraph potentially containing a vlnTable + /// multiplier + /// pdfContentByte + private void AdjustSupInfoTable(vlnParagraph pg, float scaler, PdfContentByte cb) + { + // Adjust the table if it exists + if (pg.MyGrid != null) + { + // Create lists of heights before and after shrinking sup info + Dictionary beforeRowHeight = new Dictionary(); + Dictionary afterRowHeight = new Dictionary(); + for (int i = 0; i < pg.MyGrid.RowTop.GetLength(0)-1; i++) + { + beforeRowHeight.Add(i, scaler * (pg.MyGrid.RowTop[i+1] - pg.MyGrid.RowTop[i])); + afterRowHeight.Add(i, 0); + } + // Adjust font size for each cell. + foreach (vlnCell cell in pg.MyGrid.MyCells) + { + float x = cell.MyTable.ColLeft[cell.c1]; + float w = cell.MyTable.ColLeft[cell.c2 + 1] - x; + float hBefore = scaler * pg.GetParagraphHeight(cb,cell.MyPara,"",w); + foreach (Chunk chk in cell.MyPara.Chunks) + chk.Font.Size = scaler * chk.Font.Size; + float hAfter = 1.075F * pg.GetParagraphHeight(cb,cell.MyPara,"",w);// 1.075 is a magic number that worked for Ginna. Otherwise decenders overlapped the bottom line of the cell. + cell.HContent = hAfter; + // Save tthe height after adjusting the font size to account for changes in word wrap. + afterRowHeight[cell.r1]=Math.Max(hAfter,afterRowHeight[cell.r1]); + } + for (int i = 0; i < pg.MyGrid.RowTop.GetLength(0)-1; i++) + { + pg.MyGrid.RowTop[i+1] = scaler * pg.MyGrid.RowTop[i+1];// Adjust for leading + pg.MyGrid.RowTop[i+1] += (afterRowHeight[i]-beforeRowHeight[i]); //Adjust for word wrapping + } + } + } + /// /// Adjust YOffset for Print Objects /// /// Print Object (tab, paragraph, etc.)