Swechhya / pdfUtils

R package that allow users to integrate PDF functionalities from their R code
GNU General Public License v3.0
2 stars 0 forks source link

Error in clrCall(obj, "HighLightText", text): System.ArgumentOutOfRangeException #1

Open brooksambrose opened 4 years ago

brooksambrose commented 4 years ago

First, thanks for a very cool utility, I haven't found anything else quite like it.

I have found that some words seem to cause an error, and I can't see a pattern. Here's an example file that works when highlighting the word "programs" but throws an error for the word "Programs".

2020-04InstConn-pst.pdf

Do you have a clue why some words would cause an error and others don't?

> pdfUtils::Highlightext('rClr','2020-04InstConn-pst.pdf','programs')
Text highlighted successfully.
> pdfUtils::Highlightext('rClr','2020-04InstConn-pst.pdf','Programs')
Error in clrCall(obj, "HighLightText", text) :
  Type:    System.ArgumentOutOfRangeException
Message: Argument is out of range.
Parameter name: index
Method:  iTextSharp.text.pdf.parser.TextRenderInfo get_Item(Int32)
Stack trace:
  at System.Collections.Generic.List`1[iTextSharp.text.pdf.parser.TextRenderInfo].get_Item (Int32 index) [0x00000] in <filename unknown>:0
  at System.Linq.Enumerable.ElementAt[TextRenderInfo] (IEnumerable`1 source, Int32 index) [0x00000] in <filename unknown>:0
  at SearchTextBoundary.MyTextExtractionStrategy.searchText () [0x00000] in <filename unknown>:0
  at SearchTextBoundary.MyTextExtractionStrategy.GetResultantText () [0x00000] in <filename unknown>:0
  at iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage (iTextSharp.text.pdf.PdfReader reader, Int32 pageNumber, ITextExtractionStrategy strategy) [0x00000] in <filename unknown>:0
  at EntryForR.clsEntryForR.HighLightText (System.String searchText) [0x00000] in <filename unknown>:0
  at (wrapper managed-to-native) System.Reflect
Swechhya commented 4 years ago

@brooksambrose Thanks for reporting this issue. I'll look into it and try to fix it.