• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Copy text from pdf to TextEdit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Copy text from pdf to TextEdit


  • Subject: Re: Copy text from pdf to TextEdit
  • From: Guido Tangorra <email@hidden>
  • Date: Wed, 09 Jul 2014 19:13:58 +0200

​Hey ​Emmanuel,
finally I’ve solved it!

First of all I used the command line tool pdftotext to convert my PDF in a text file. SMILE’s readtext doesn't retain enough of the formatting of the PDF to parse.

set the_text to do shell script "/usr/local/bin/pdftotext -layout -enc UTF-8" & quoted form of POSIX path of the_file & " -"

Then in SMILE I searched the desired type of questions with a set of regular expressions.

set qText to find text regEx in the_text with regexp and string

I saved the result in a variable.

set outDoc to outDoc & qText & return & "----------" & return & return

Finally I have created a new text document to paste the output

tell application "TextWrangler"
    activate
    set myDocument to make new text document
    set text of myDocument to outDoc
end tell


Thank you.
Special thanks to Christopher Stone for his precious suggestions.


Message: 4
Date: Tue, 17 Jun 2014 13:18:39 +0200
From: Emmanuel LEVY <email@hidden>
To: AppleScript Listserv <email@hidden>
Subject: Re: Copy text from pdf to TextEdit
Message-ID: <email@hidden>
Content-Type: text/plain; charset=us-ascii

Not sure I understand what the problem is exactly, but just in case it helps I mention that Smile's "readtext" command can read text from PDFs (and from URLs and a lot of things by the way).

Best,
Emmanuel

On Jun 17, 2014, at 12:07 PM, Guido Tangorra wrote:

> Hi,
> I want to create a text file from a pdf source.
> I have a pdf with 1000 multiple choice questions like this:
>
> 1 Question 1
>
> A Answer A
> B Answer B
> C Answer C
> D Answer D
> E Answer E
> --------------------------------------------------------
> .
> .
> .
> .
> 100 Question 100
>
> A Answer A
> B Answer B
> C Answer C
> D Answer D
> E Answer E
> -------------------------------------------------------------
> .
> .
> .
> .
> 1000 Question 1000
>
> A Answer A
> B Answer B
> C Answer C
> D Answer D
> E Answer E
>
>
> The dotted line is the separator from a question to another.
> I want to create a txt with 50 random questions from the 1000 above.
> Any suggestions?
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Script won't run consistently
  • Next by Date: Re: Script won't run consistently
  • Previous by thread: Re: Script won't run consistently
  • Next by thread: Help scripting configuration and customization for multiple installs
  • Index(es):
    • Date
    • Thread