Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:00:32+00:00 2026-06-10T23:00:32+00:00

This is a follow on from this question We figured out how to extract

  • 0

This is a follow on from this question

We figured out how to extract text marked for redaction using the code below.

However, there are additional leading and trailing characters captured beyond the text marked for redaction.

For example, if a sentence is marked for redaction in the source PDF document, the code below also captures the last few characters of the preceding sentence and the first few characters of the next sentence.

Is anybody able to see a problem in the code below?

  for (int i = 1; i <= rdr.NumberOfPages; i++)
                {
                    // Get pages and corresponding annotations

                    PdfDictionary dict = rdr.GetPageN(i);
                    PdfArray annots = dict.GetAsArray(PdfName.ANNOTS);

                    foreach (var annItem in annots.ArrayList)
                    {
                        PdfDictionary d = PdfReader.GetPdfObject(annItem) as PdfDictionary;
                        PdfName typ = d.GetAsName(PdfName.SUBTYPE);
                        if (typ.ToString().StartsWith("/Redact"))
                        {
                            sb = new StringBuilder();
                            PdfObject o1 = d.Get(PdfName.QUADPOINTS);
                            PdfArray arr2 = o1 as PdfArray;
                            int numLines = arr2.ArrayList.Count / 8;
                            for (int k = 0; k < numLines; k++)
                            {
                                llx = float.Parse(arr2[(0 + k * 8)].ToString());
                                lly = float.Parse(arr2[(1 + k * 8)].ToString());
                                urx = float.Parse(arr2[(6 + k * 8)].ToString());
                                ury = float.Parse(arr2[(7 + k * 8)].ToString());

                                Rectangle rect = new Rectangle(llx, lly, urx, ury, 1);

                                List<RenderFilter> filters = new List<RenderFilter>();
                                filters.Add(new RegionTextRenderFilter(rect));
                                strategy = new FilteredTextRenderListener(new LocationTextExtractionStrategy(),
                                    filters.ToArray<RenderFilter>());
                                // We get the text but get extra leading/trailing chars that are not in redaction.
                                sb.Append(PdfTextExtractor.GetTextFromPage(rdr, i, strategy));
                            }
                            Console.WriteLine("Page: " + i.ToString());
                            Console.WriteLine(sb.ToString() + Environment.NewLine);
                            sb.Clear();

                       }
                    }
                }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:00:35+00:00Added an answer on June 10, 2026 at 11:00 pm

    For the sake of completeness, this question was answered on the iText mailing list:
    http://thread.gmane.org/gmane.comp.java.lib.itext.general/62918

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow up from my previous question I have this code basically
This is a follow up from a question of mine that was just answered
This is a follow-on from this question, in which I was trying to suppress
This is a follow up question from Calling constructor in return statement . This
This is a follow-on question from the one I asked here . Can constraints
This is a follow on from my previous question although this is about something
This is a follow-on from a previous SO question Anchoring CSS Repeating Background Image
This question is a follow on from this one ... I am binding to
(there is a follow up to this question here ) I am working on
this follows on from my last question which I thought was answered but for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.