From 59bc89e4f227ed00b85ccf4c30e9baade9e45344 Mon Sep 17 00:00:00 2001 From: Rich Date: Sat, 24 Jan 2015 19:09:45 +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.Svg.Library/iTextSharp.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/PROMS/Volian.Svg.Library/iTextSharp.cs b/PROMS/Volian.Svg.Library/iTextSharp.cs index b0e4b966..01ccb01b 100644 --- a/PROMS/Volian.Svg.Library/iTextSharp.cs +++ b/PROMS/Volian.Svg.Library/iTextSharp.cs @@ -637,11 +637,27 @@ namespace Volian.Svg.Library return Element.ALIGN_LEFT; } } + 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(); // Draw's using PdfContentByte are for drawing PageList items. public override void Draw(PdfContentByte cb, SvgScale scale, Svg mySvg, SvgPartInheritance myParent) { string text = mySvg.OnProcessText(Text, this, scale); if (text == string.Empty) return; + // Replace hard hyphen with hyphen when printing pagelist items + // this will enable the hyphens to be found in a PDF search + if(text.Contains("\\u8209?")) + text = text.Replace("\\u8209?", "-"); SetupInheritance(myParent.MyInheritedSettings); float yScale = (myParent is SvgGroup && (myParent as SvgGroup).Description.ToUpper() == "ABSOLUTE") ? scale.AbsY(cb, Y): scale.Y(cb, Y); cb.SaveState(); @@ -667,7 +683,11 @@ namespace Volian.Svg.Library float x = (myParent is SvgGroup && (myParent as SvgGroup).Description.ToUpper() == "ABSOLUTE") ? scale.AbsX(X): scale.X(X); float w = 0; // chk.GetWidthPoint(); foreach (Chunk chk in ph.Chunks) + { w += chk.GetWidthPoint(); + // Change the chunks to only split on spaces rather than spaces and hyphens + chk.SetSplitCharacter(mySplitter); + } switch (Justify) { //case SvgJustify.Left: