We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Loaded Document FindText is skipping every other value

I am evaluating the pdf control for redacting purposes. When I extractText from page, i see all the text values I need to redact. When I then use FindText to create a boundry area for redaction, it only finds the items if they are separated by 10-15 pixels in height. It finds every other and redacts great. When I try multiple passes, it still will not find them.  Any suggestions? Could it be the font size the document uses? Fonts are CourierStd (Type 1), ArialMT (truetype), Microsoft Sans Serif  (truetype).
Maybe font size 6 or 7.



PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Input/test.pdf");
PdfFont font = new PdfTrueTypeFont(new Font("CourierStd", 6));
foreach (PdfLoadedPage page in loadedDocument.Pages)
            {
//find all text that needs to be redacted
 var acctNr6 = Regex.Matches(extractedText, @"4865(\d{12})", RegexOptions.IgnorePatternWhitespace);
var fText = acctNr6.Cast<Match>().Where(x => x.Value != "0000000000000000").Select(match => match.Value).Distinct().ToList();

//find actual location of extractedText need redact
List<MatchedItem> oRetDat = new List<MatchedItem>();
var res = loadedDocument.FindText(pageRes.Value.ToList(), pageRes.Key, out oRetDat);

foreach (MatchedItem oRect in oRetDat)
                    {
                        RectangleF redactionBound = new RectangleF(oRect.Bounds.X, oRect.Bounds.Y,
                                    (oRect.Bounds.Width), (oRect.Bounds.Height-2));

                        page.Graphics.DrawRectangle(PdfBrushes.White, redactionBound);
                        page.Graphics.DrawString(oRect.Text.Replace('-',' ').Substring(oRect.Text.Length - 4, 4), font, PdfBrushes.Black, redactionBound.X, redactionBound.Y);
                    }

loadedDocument.Save("RedactedPDF.pdf");
            loadedDocument.Close(true);

            Process.Start("RedactedPDF.pdf");
}


3 Replies

AA Akshaya Arivoli Syncfusion Team November 4, 2019 10:20 AM UTC

Hi Greg , 
 
Thank you for contacting Syncfusion support. 

We are unable to reproduce the reported issue with the provided details and we suspect that the issue is document specific. We have shared the sample in which we have tried to reproduce the issue in the below link, 


Please try this and revert us with the more details about your issue, modified sample, PDF document and Essential studio version if you are still facing the issue. These details will be helpful for us to investigate more on your issue and assist you better. 

Regards, 
Akshaya 



GT Greg Thomas November 6, 2019 02:31 PM UTC

Akshaya,

Thank you for responding, I will check the sample sent. I am trying to get authorization to share one of the page that we are having issues with and will get back.

Thank You,

Greg


SA Sabari Anand Senthamarai Kannan Syncfusion Team November 7, 2019 01:53 PM UTC

Hi Greg , 
 
We will wait to hear the test results from you. Please revert us if you have any concerns on the provided details. 
 
Regards, 
Sabari Anand

Loader.
Live Chat Icon For mobile
Up arrow icon