1

I am using PDFKitten code. I have fixed all the issues regarding parsing of CMap, /Differences in that.

I have a pdf with TrueType and Type1 fonts. I have parsed its differences and widths array.
However whenever I try to select or search text highlight is shown on the wrong position. What can be the problem?

I have applied MediaBox transform to drawing rect. It worked for some other pdfs but its not working for this. What more I have to do to solve this problem?

I have checked link for similar issue but solution is not working.

Thanks.

Adding the screenshot :

enter image description here

Community
  • 1
  • 1
Swaroop
  • 501
  • 4
  • 18
  • Can you post a screenshot of the displayed page and the highlight drawn on the page and also indicate where the highlight should be placed actually? – iPDFdev Jul 07 '15 at 08:43
  • Added the screen shot. I want to select the word "transport" and selection is started after "tr". – Swaroop Jul 07 '15 at 09:08
  • What is the position (ll, ur coordinates) you computed for 'transport' word? – iPDFdev Jul 07 '15 at 12:15
  • (CGRect) rect = (origin = (x = 403.59802068642199, y = 74.832286867199969), size = (width = 55.572233502335052, height = 11.639995343999999)) – Swaroop Jul 07 '15 at 12:21
  • My calculations for x return 394.112177. The TJ operator that displays the text "Is the major transport protocol in" contains both positive and negative values for text shift, thus shifting text position to the left or right. I assume you shift text position only to the right and this causes the x position to be greater than expected. – iPDFdev Jul 10 '15 at 13:25
  • I tried to move it both ways but for some words it moved to left and for some word it moved to right. When the space is detected, I move it compulsory to right.. What am I doing wrong? – Swaroop Jul 13 '15 at 07:24

1 Answers1

0

It turns out the glyph for particular unicode was not identified correctly. It is the bug in PDFKitten. Resolved it by adding Glyph model by keeping it's width. While calculating width instead of Mapping back to glyph I use glyph from model to get the width from the font.

Swaroop
  • 501
  • 4
  • 18