Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 131327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:05:16+00:00 2026-05-11T06:05:16+00:00

I need to parse some text from pdfs but the pdf formatting results in

  • 0

I need to parse some text from pdfs but the pdf formatting results in extremely unreliable spacing. The result is that I have to ignore the spaces and have a continuous stream of non-space characters.

Any suggestions on how to parse the string and put spaces back into the string by guessing?

I’m using ruby. Or should I say I’musingruby?

Edit: I’ve pulled the text out using pdf-reader. Some of the pdf files are nicely formatted and some are not. An example of text mixed with positioning:

.7aspe-5.5cts-715.1o0.6f-708.5f-0.4aces-721.4that-716.3are-720.0i-1.8mportant-716.3in-713.9soc-5.5i-1.8alcommunica6.6tion6.3.-711.6Althoug6.3h-708.1m-1.9od6.3els-709.3o6.4f-702.8f5.4ace-707.9proc6.6essing-708.2haveproposed-611.2ways-615.5to-614.7deal-613.2with-613.0these-613.9diff10.4erent-613.7tasks,-611.9it-617.1remainsunclear-448.0how-450.7these-443.2mechanisms-451.7might-446.7be-447.7implemented-447.2in-450.3visualOne-418.9model-418.8of-417.3human-416.4face-421.9processing-417.5proposes-422.7that-419.8informa-tion-584.5is-578.0processed-586.1in-583.1specialised-584.7modules-577.0(Breen-584.4et-582.9al.,-582.32002;Bruce-382.1and-384.0Y92.0oung,-380.21986;-379.2Haxby-379.9et-380.5al.,-

and if I print just string data (I added returns at the end of each line to keep it from messing up the layout here:

‘Distinctrepresentationsforfacialidentityandchangeableaspectsoffacesinthehumantemporal lobeTimothyJ.Andrews*andMichaelP.EwbankDepartmentofPsychology,WolfsonResearchInstitute, UniversityofDurham,UKReceived23December2003;revised26March2004;accepted27July2004Availab leonline14October2004Theneuralsystemunderlyingfaceperceptionmustrepresenttheunchanging featuresofafacethatspecifyidentity,aswellasthechangeableaspectsofafacethatfacilitates ocialcommunication.However,thewayinformationaboutfacesisrepresentedinthebrainremainsc ontroversial.Inthisstudy,weusedfMRadaptation(thereductioninfMRIactivitythatfollowsthe repeatedpresentationofidenticalimages)toaskhowdifferentface-andobject-selectiveregionsofvisualcortexcontributetospecificaspectsoffaceperception’

The data is spit out by callbacks so if I print each string as it is returned it looks like this:

‘The

-571.3

neural

-573.7

system

-577.4

underly

13.9

ing

-577.2

face

-573.0

perc

13.7

eption

-574.9

must

-572.1

repr

20.8

esent

-577.0

the

unchangin

14.4

g

-538.5

featur

16.5

es

-529.5

of

-536.6

a

-531.4

face

‘

On examination it looks like the true spaces are large negative numbers < -300 and the false spaces are much smaller positive numbers. Thanks guys. Just getting to the point where i am asking the question clearly helped me answer it!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:05:17+00:00Added an answer on May 11, 2026 at 6:05 am

    PDF doesn’t only store spaces as space characters, but also uses layout commands for spacing (so it doesn’t print a space, but moves the ‘pen’ to the right). Perhaps you should have a look at the PDF reference (the big PDF on the bottom of the site), Chapter 9 ‘Text’ should be what you’re looking for.

    EDIT: After reading your comment to Lazarus’ answer, this doesn’t seem to be what you’re looking for. I think you should try to get a word list from somewhere and try to split your text using it. A good strategy would be to do that using recursion, because for example:

    ‘meandyou’

    The first word could be ‘me’ or ‘mean’, but if you try ‘mean’, ‘dyou’ doesn’t make sense, so it will be ‘me’, same for the next word that could be ‘a’ or ‘an’ or ‘and’, only ‘and’ makes sense.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 258k
  • Answers 258k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you are using the WorkflowServiceHost, or a XAMLX, to… May 13, 2026 at 10:58 am
  • Editorial Team
    Editorial Team added an answer The CONNECT command is used by HTTP proxy servers to… May 13, 2026 at 10:58 am
  • Editorial Team
    Editorial Team added an answer In my deployment we have a "SolutionName_UpdateFields" feature. We implement… May 13, 2026 at 10:58 am

Related Questions

It's always hard for me to understandably (especially in English which isn't my first
I'm trying to parse some HTML with XPath. Following the simplified XML example below,
Using the following text as a sample, I need to be able to extract
I need to be able to store a date (year/month/day) with no time component.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.