From 638fea272e853e3e2044dd7438aa463ff249f4e5 Mon Sep 17 00:00:00 2001 From: Rich Date: Sat, 24 Jan 2015 19:09:08 +0000 Subject: [PATCH] Replace Hard Hyphens with normal hyphen so the PDF search for hyphens will work properly Support using regular hyphens as hard-hyphens --- PROMS/Volian.Controls.Library/DisplayText.cs | 5 ++++- PROMS/Volian.Print.Library/Rtf2Pdf.cs | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index cd29b727..72de17c3 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -121,7 +121,7 @@ namespace Volian.Controls.Library _MyItemInfo = itemInfo; OriginalText = InfoText; if (OriginalText.Contains("Prerequisite") && epMode == E_EditPrintMode.Print) - OriginalText = Regex.Replace(OriginalText, @"\\{Prerequisite Step: .*?\\}", ""); + OriginalText = Regex.Replace(OriginalText, @"\\{Prerequisite Step: .*?\\}", ""); TextFont = itemInfo.GetItemFont();//GetItemFont(); // if in print mode, and this is the HLS of a smart template (checklist formats) see if the hls // splits across 2 lines. @@ -167,6 +167,9 @@ namespace Volian.Controls.Library } } text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted, underlineAfterDashSpace); + // Replace Hard Hyphens with normal hyphen so the PDF search for hyphens will work properly + if (text.Contains(@"\u8209?") && epMode == E_EditPrintMode.Print) + text = OriginalText.Replace(@"\u8209?", "-"); StartText = text; ProfileTimer.Pop(profileDepth); diff --git a/PROMS/Volian.Print.Library/Rtf2Pdf.cs b/PROMS/Volian.Print.Library/Rtf2Pdf.cs index cc19ede7..71540dce 100644 --- a/PROMS/Volian.Print.Library/Rtf2Pdf.cs +++ b/PROMS/Volian.Print.Library/Rtf2Pdf.cs @@ -88,8 +88,23 @@ namespace Volian.Print.Library return retval; } } + public class VlnSplitCharacter : ISplitCharacter + { + public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) + { + return (cc[current] == ' '); + } + public bool IsSplitCharacter(char c) + { + return (c == ' '); + } + } + public static VlnSplitCharacter mySplitter = new VlnSplitCharacter(); public static float TextAt(PdfContentByte cb, Paragraph iParagraph, float x, float y, float width, float height, string debugText, float yBottomMargin) { + // Change the chunks to only split on spaces rather than spaces and hyphens + foreach (Chunk chk in iParagraph) + chk.SetSplitCharacter(mySplitter); VlnSvgPageHelper _MyPageHelper = cb.PdfWriter.PageEvent as VlnSvgPageHelper; PdfLayer textLayer = _MyPageHelper == null ? null : _MyPageHelper.TextLayer; float left = x + Offset.X;