@Jcis, I actually managed a workaround to handle multiple requests, using your example as a starting point. I use your project as a reference in a C # project and change what it does. Instead of just highlighting, I actually draw a white rectangle around the search term, and then using the coordinates of the rectangle, place the form field. I also had to change the recording mode as content in order to get content in order to completely block the search text. In fact, I created an array of strings of search terms, and then using the for loop, I create as many text fields as I need.
Test.Form1 formBuilder = new Test.Form1(); string[] fields = new string[] { "%AccountNumber%", "%MeterNumber%", "%EmailFieldHolder%", "%AddressFieldHolder%", "%EmptyFieldHolder%", "%CityStateZipFieldHolder%", "%emptyFieldHolder1%", "%emptyFieldHolder2%", "%emptyFieldHolder3%", "%emptyFieldHolder4%", "%emptyFieldHolder5%", "%emptyFieldHolder6%", "%emptyFieldHolder7%", "%emptyFieldHolder8%", "%SiteNameFieldHolder%", "%SiteNameFieldHolderWithExtraSpace%" }; //int a = 0; for (int a = 0; a < fields.Length; ) { string[] fieldNames = fields[a].Split('%'); string[] fieldName = Regex.Split(fieldNames[1], "Field"); formBuilder.PDFTextGetter(fields[a], StringComparison.CurrentCultureIgnoreCase, htmlToPdf, finalhtmlToPdf, fieldName[0]); File.Delete(htmlToPdf); System.Array.Clear(fieldNames, 0, 2); System.Array.Clear(fieldName, 0, 1); a++; if (a == fields.Length) { break; } string[] fieldNames1 = fields[a].Split('%'); string[] fieldName1 = Regex.Split(fieldNames1[1], "Field"); formBuilder.PDFTextGetter(fields[a], StringComparison.CurrentCultureIgnoreCase, finalhtmlToPdf, htmlToPdf, fieldName1[0]); File.Delete(finalhtmlToPdf); System.Array.Clear(fieldNames1, 0, 2); System.Array.Clear(fieldName1, 0, 1); a++; }
It bounces the PDFTextGetter function in your example back and forth between the two files until it reaches the finished product. It works very well, and that would not be possible without your initial project, so thanks for that. I also changed your VB to display a text field, for example:
For Each rect As iTextSharp.text.Rectangle In MatchesFound cb.Rectangle(rect.Left, rect.Bottom + 1, rect.Width, rect.Height + 4) Dim field As New TextField(stamper.Writer, rect, FieldName & Fields) Dim form = stamper.AcroFields Dim fieldKeys = form.Fields.Keys stamper.AddAnnotation(field.GetTextField(), page) Fields += 1 Next
I just decided to share what I managed to do with your project as a basis. It even increments the field names as I need them. I also had to add a new parameter to your function, but it should not be listed here. Thanks again for this great start.