I need to do a low level text extraction using PRTokeniser
For some PDF files everything is fine but for some others I get empty strings (or rather a string made up by empty boxes or empty characters).
All such files follow this pattern:
endobj
7 0 obj
<</BaseFont/RDZRPI+TimesNewRoman/FontDescriptor 8 0 R/Type/Font
/FirstChar 1/LastChar 10/Widths[ 444 500 444 500 444 333 500 500 278 250]
/Encoding 11 0 R/Subtype/TrueType>>
endobj
11 0 obj
<</Type/Encoding/BaseEncoding/WinAnsiEncoding/Differences[
1/a/b/c/d/e/f/g/h/i/space]>>
endobj
Each character in the token stringvalue is not an ASCII or ANSI code but the index of the differences array. For instance if I have a string like "abc" I would get 1,2,3. Then iTextSharp would understand such codes as ASCII codes and would render them like empty square boxes or any other character.
Therefore I would need to get the subset array: number 1 is "a", number 2 is "b"...
The problem is that the basefont.differences array has only empty values and therefore I don't know how to rebuild the string.
On the other hand strategy.GetResultantText rendes the page content properly, but I need much more detail and that’s way I'm using PRTokeniser, although I'm stuck with this font problem.
Any ideas?
The PDF streams are all like this:
/FirstChar 1/LastChar 8/Widths[ 722 444 278 500 250 944 333 500]
/Encoding 11 0 R/Subtype/TrueType>>
endobj
11 0 obj
<</Type/Encoding/BaseEncoding/WinAnsiEncoding/Differences[
1/H/e/l/o/space/W/r/d]>>
In this case there is only this sentence in the PDF: Hellow Word. Therefore the chars array would be:
1 H 2 e 3 l 4 o 5 space 6 W 7 r 8 d
I need to find such an array using iTextSharp in order to decipher the string tokens.
Thanks