Click here to Skip to main content
15,607,524 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using Pdf reader and Extractor in My Coding.My problem is Below code is Extract one page Text, but i need rectangle or highlighted text only.

  PdfReader reader = new PdfReader(Server.MapPath(path));
//Document document = new Document();
StringBuilder text = new StringBuilder();
iTextSharp.text.Rectangle size = reader.GetPageSizeWithRotation(1);
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(10, 30, 50, 70);
RenderFilter[] renderFilter = new RenderFilter[1];
renderFilter[0] = new RegionTextRenderFilter(rect);
ITextExtractionStrategy textExtractionStrategy = newFilteredTextRenderListener(new LocationTextExtractionStrategy(), renderFilter);
  // string text = PdfTextExtractor.GetTextFromPage(reader, 1, textExtractionStrategy);
TextBox1.Text = PdfTextExtractor.GetTextFromPage(reader,reader.NumberOfPages,strategy).ToString();
Updated 18-Apr-14 11:33am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900