Storing, in order, text from a pdf

Discussion in 'iOS Programming' started by Ja Di ksw, Jan 14, 2014.

  1. Ja Di ksw macrumors 65816

    Ja Di ksw

    Joined:
    Apr 9, 2003
    #1
    Hi everyone,
    Is there a simple way to read/store the words from a pdf in order (for example, putting them in a NSMutableArray?) so each word can be retrieved later?
    Thanks!
     
  2. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #2
    You could read the file into an NSString and then use the NSString method "componentsSeparatedByString:"

    This should help
     
  3. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #3
    -Convert the PDF to an NSString
    -Use componentsSeparatedByString to create an array of words
    -Use sortedArrayUsingSelector:mad:selector(caseInsensitiveCompare) to sort the array.

    You'll have tons of duplicate words. You might want to remove those. To do that you could convert the array into an NSOrderedSet or NSMutableOrderedSet and sort that.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    How hard is this step?
     
  5. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #5
    I actually don't know for sure. I've never needed to.
     
  6. waterskier2007 macrumors 68000

    waterskier2007

    Joined:
    Jun 19, 2007
    Location:
    White Lake, MI
    #6
    I completely glossed over the fact that it said PDF to NSString. A pdf could be tough, especially given that a lot of pdfs are created differently.

    through a quick google search I found this

    https://github.com/zachron/pdfiphone
     
  7. Ja Di ksw thread starter macrumors 65816

    Ja Di ksw

    Joined:
    Apr 9, 2003
    #7
    Thanks for all the help (and sorry about my late reply, been insanely busy). I'll give it a go this week and see how it works.
     

Share This Page