how to read an specific page into pdf document?

Peter M. Brigham, MD pmbrig at gmail.com
Wed Oct 19 09:44:01 EDT 2011


On Oct 18, 2011, at 3:47 PM, Francis Nugent Dixon wrote:

> Hi from beautiful Brittany,
> 
> Graham wrote :
> 
>> Where does the PDF page appear? I mean is it in a stack window,
> 
>> and could it be manipulated by a LiveCode program ?
> 
> The answer is YES !
> 
> I may be a little late on this thread, 'cos I've been trying
> to solve the problem myself. I appear to have made progress
> - to whit : pick up a page of a pdf file and get it as text
> into a stack. Save it on an external file, then read it back
> into the stack - Long-winded but effective.
> 
> Don't ask me what happens to non-text data in the page - I
> haven't got that far, YET !
> 
> After playing about with Skim, and scanning all examples
> available on the net, I think you can do just about anything
> with Skim and AppleScript.
> 
> Of course, my example was developed on a MAC.
> 
> File "SkimTest1.pdf" contains text ONLY.
> "MyPagesC" is a field containing the required page number.
> "MySkim" is the reception field in my stack
> 
> TestStack available on request (save you coding it all up)
> 
> Be careful of line wraps.
> 
> Best Regards
> 
> -Francis
> 
> 
>   put "tell application " & quote & "Skim" & quote into line 1 of GVMasterScript
>   put "set " & LVDeskTop & " to path to desktop as string" into line 2 of GVMasterScript
>   put "open (" & LVDeskTop & " & " & quote & "SkimTest1.pdf" & quote & ")" into line 3 of GVMasterScript
>   put "tell document 1" into line 4 of GVMasterScript
>   put char 1 to 3 of field "MyPagesC" into GVPage
>   put "go to page " & GVPage into line 5 of GVMasterScript
>   put "set " & GVTextData & " to (get text for page " & GVPage & ")" into line 6 of GVMasterScript
>   put "tell application " & quote & "TextEdit" & quote into line 7 of GVMasterScript
>   put "activate" into line 8 of GVMasterScript
>   put "make new document" into line 9 of GVMasterScript
>   put "set text of document 1 to GVTextData as text" into line 10 of GVMasterScript
>   put "save document 1 in (LVDeskTop " & " & " & quote & "SkimOut.txt" & quote & ")" into line 11 of GVMasterScript
>   put "end tell" into line 12 of GVMasterScript
>   put "end tell" into line 13 of GVMasterScript
>   put "activate" into line 14 of GVMasterScript
>   put "end tell" into line 15 of GVMasterScript
>   --
>   --     AppleScript is now complete. So execute it !
>   --
>   do GVMasterScript as AppleScript
>   put GVDeskTop & "/" & "SkimOut.txt" into LVSkimName
>   if there is a file LVSkimName then
>      open file LVSkimName
>      put 0 into LVSkimLines
>      repeat forever
>         read from file LVSkimName until return
>         put it into LVInputArea
>         if LVInputArea is empty then exit repeat
>         add 1 to LVSkimLines
>         put LVInputArea into line LVSkimLines of field MySkim
>      end repeat
>      close file LVSkimName
>      show field "MySkim"
>   end if

Can you not just return GVTextData as the result from your AppleScript and then put that into your field directly? Do you have to go through writing it to a file then getting it from the file?

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig





More information about the use-livecode mailing list