Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search can't find strings with small spaces? #6

Open
Pstoppani opened this issue Nov 10, 2011 · 2 comments
Open

Search can't find strings with small spaces? #6

Pstoppani opened this issue Nov 10, 2011 · 2 comments

Comments

@Pstoppani
Copy link

In this file http://dl.dropbox.com/u/39382628/test2.pdf, the word "test" is not found, even though the file contains just two words and they are both "test".

It seems that there are some spaces between some of the characters in the array passed to the TJ handler . These spaces cause the Scanner to reset its stringDetector which prevents it from finding the complete string.

Here is what I'm seeing:

2011-11-09 17:00:45.563 neuAnnotatePlus[12749:1f303] didScanString: t
2011-11-09 17:00:45.563 neuAnnotatePlus[12749:1f303] didScanSpace: value=111.00000000, width=0.11100001
2011-11-09 17:00:45.580 neuAnnotatePlus[12749:1f303] didScanString: e
2011-11-09 17:00:45.580 neuAnnotatePlus[12749:1f303] didScanSpace: value=-0.20000000, width=-0.00020000
2011-11-09 17:00:45.581 neuAnnotatePlus[12749:1f303] didScanString: st
2011-11-09 17:00:45.585 neuAnnotatePlus[12749:1f303] didScanSpace: value=0.20000000, width=0.00020000
2011-11-09 17:00:45.585 neuAnnotatePlus[12749:1f303] didScanString:
2011-11-09 17:00:45.586 neuAnnotatePlus[12749:1f303] didScanString:
2011-11-09 17:00:45.587 neuAnnotatePlus[12749:1f303] didScanString: t
2011-11-09 17:00:45.587 neuAnnotatePlus[12749:1f303] didScanSpace: value=0.20000000, width=0.00020000
2011-11-09 17:00:45.588 neuAnnotatePlus[12749:1f303] didScanString: e
2011-11-09 17:00:45.588 neuAnnotatePlus[12749:1f303] didScanSpace: value=-0.20000000, width=-0.00020000
2011-11-09 17:00:45.589 neuAnnotatePlus[12749:1f303] didScanString: st

@KurtCode
Copy link
Owner

Interesting. I'll check it out. Thanks for the sample file.

  • Marcus

On 10 nov 2011, at 02:04, Pstoppani
reply@reply.github.com
wrote:

In this file http://dl.dropbox.com/u/39382628/test2.pdf, the word "test" is not found, even though the file contains just two words and they are both "test".

It seems that there are some spaces between some of the characters in the array passed to the TJ handler . These spaces cause the Scanner to reset its stringDetector which prevents it from finding the complete string.

Here is what I'm seeing:

2011-11-09 17:00:45.563 neuAnnotatePlus[12749:1f303] didScanString: t
2011-11-09 17:00:45.563 neuAnnotatePlus[12749:1f303] didScanSpace: value=111.00000000, width=0.11100001
2011-11-09 17:00:45.580 neuAnnotatePlus[12749:1f303] didScanString: e
2011-11-09 17:00:45.580 neuAnnotatePlus[12749:1f303] didScanSpace: value=-0.20000000, width=-0.00020000
2011-11-09 17:00:45.581 neuAnnotatePlus[12749:1f303] didScanString: st
2011-11-09 17:00:45.585 neuAnnotatePlus[12749:1f303] didScanSpace: value=0.20000000, width=0.00020000
2011-11-09 17:00:45.585 neuAnnotatePlus[12749:1f303] didScanString:
2011-11-09 17:00:45.586 neuAnnotatePlus[12749:1f303] didScanString:
2011-11-09 17:00:45.587 neuAnnotatePlus[12749:1f303] didScanString: t
2011-11-09 17:00:45.587 neuAnnotatePlus[12749:1f303] didScanSpace: value=0.20000000, width=0.00020000
2011-11-09 17:00:45.588 neuAnnotatePlus[12749:1f303] didScanString: e
2011-11-09 17:00:45.588 neuAnnotatePlus[12749:1f303] didScanSpace: value=-0.20000000, width=-0.00020000
2011-11-09 17:00:45.589 neuAnnotatePlus[12749:1f303] didScanString: st


Reply to this email directly or view it on GitHub:
#6

@Pstoppani
Copy link
Author

My naive (just barely into the PDF spec :) fix:

"

  • (CGFloat)widthOfCharacter:(unichar)character withFontSize:(CGFloat)fontSize
    {
    NSNumber *key = [NSNumber numberWithInt:character];
    NSNumber *numWidth = [self.widths objectForKey:key];
    float width = 0.;

    if (numWidth)
    {
    width = [numWidth floatValue];
    }
    else if (self.fontDescriptor.missingWidth > 0)
    {
    width = self.fontDescriptor.missingWidth;
    }
    else if (self.fontDescriptor.averageWidth > 0)
    {
    width = self.fontDescriptor.averageWidth;
    }
    else if (self.fontDescriptor.maxWidth > 0)
    {
    width = self.fontDescriptor.maxWidth;
    }

    return width * fontSize;
    }
    "

Here is a real world test file: http://dl.dropbox.com/u/8069980/neuAnnotate%20Guide.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants