From 3b54c091c9b7a8a7fb58034d409d22da97f769eb Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 10 May 2012 15:45:34 +0000 Subject: [PATCH] Added logic to eliminate WordWrap differences that occur due to 16-Bit issues where the last line in a paragraph wraps at one character wider than the rest of the paragraph. For 32-bit this is only done when printing in Debug mode. Add PromsPrinter to constructor for VlnPageHelper --- .../Volian.Print.Library/VlnSvgPageHelper.cs | 9 ++++- PROMS/Volian.Print.Library/vlnPrintObject.cs | 35 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index ab5c227e..4fd585c7 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -408,9 +408,16 @@ namespace Volian.Print.Library vcb.YChangeBarBottomExtend >= (cb.YChangeBarBottomExtend - vlnPrintObject.SixLinesPerInch)) return true; return false; } - public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection) : base() + private PromsPrinter _MyPromsPrinter; + public PromsPrinter MyPromsPrinter + { + get { return _MyPromsPrinter; } + set { _MyPromsPrinter = value; } + } + public VlnSvgPageHelper(VEPROMS.CSLA.Library.SectionInfo mySection,PromsPrinter myPromsPrinter) : base() { MySection = mySection; + MyPromsPrinter = myPromsPrinter; } private Volian.Svg.Library.Svg BuildSvg(VEPROMS.CSLA.Library.SectionInfo mySection) { diff --git a/PROMS/Volian.Print.Library/vlnPrintObject.cs b/PROMS/Volian.Print.Library/vlnPrintObject.cs index 82a76bfc..efd72750 100644 --- a/PROMS/Volian.Print.Library/vlnPrintObject.cs +++ b/PROMS/Volian.Print.Library/vlnPrintObject.cs @@ -112,6 +112,41 @@ namespace Volian.Print.Library return GetParagraphHeight(cb, iParagraph, width, true); } public static float GetParagraphHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException) + { + VlnSvgPageHelper ph = null; + if(cb != null) ph = cb.PdfWriter.PageEvent as VlnSvgPageHelper; + float heightAll = GetHeight(cb, iParagraph, width, throwException); + if (ph != null && ph.MyPromsPrinter.DebugOutput) + { + Chunk chk = RemoveLastCharacter(iParagraph); + float heightAllButOne = GetHeight(cb, iParagraph, width, throwException); + if (heightAll != heightAllButOne) + return heightAllButOne; + if (chk != null) + RestoreLastCharacter(iParagraph, chk); + } + return heightAll; + } + private static void RestoreLastCharacter(Paragraph iParagraph, Chunk chk) + { + iParagraph.RemoveAt(iParagraph.Count - 1); + iParagraph.Add(chk); + } + private static Chunk RemoveLastCharacter(Paragraph iParagraph) + { + if (iParagraph.Count == 0) + return null; + object obj = iParagraph[iParagraph.Count-1]; + Chunk chk = obj as Chunk; + if (chk == null) + Console.WriteLine("Here"); + iParagraph.RemoveAt(iParagraph.Count - 1); + string s = chk.Content; + s = s.Substring(0,s.Length - 1); + iParagraph.Add(new Chunk(s,chk.Font)); + return chk; + } + private static float GetHeight(PdfContentByte cb, Paragraph iParagraph, float width, bool throwException) { ColumnText myColumnText = new ColumnText(cb); myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin