Code Monkey home page Code Monkey logo

Comments (2)

KurtCode avatar KurtCode commented on August 29, 2024

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

  • Marcus

On 10 nov 2011, at 02:04, Pstoppani
[email protected]
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

from pdfkitten.

Pstoppani avatar Pstoppani commented on August 29, 2024

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

from pdfkitten.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.