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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Loaded Document FindText is skipping every other value

Thread ID:

Created:

Updated:

Platform:

Replies:

148750 Nov 1,2019 06:55 PM UTC Nov 7,2019 01:53 PM UTC ASP.NET Web Forms 3
loading
Tags: PdfViewer
Greg Thomas
Asked On November 1, 2019 06:55 PM UTC

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");
}


Akshaya Arivoli [Syncfusion]
Replied On 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 


Greg Thomas
Replied On 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

Sabari Anand Senthamarai Kannan [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon