how to read an specific page into pdf document?

Graham Samuel livfoss at mac.com
Wed Oct 19 09:41:54 EDT 2011


Hi from beautiful Languedoc-Roussillon,

Francis, this is interesting (particularly as I had never heard of Skim, which looks like a very useful app) but sadly doesn't work for me because I want a cross-platform solution that captures bitmaps - the complete opposite of what you have done.

Incidentally, why didn't you compose your AppleScript script in a field while you were coding and then just execute it - it seems like hard work to do all those 'put' commands with quotes and so on spelled out. Or am I missing something?

The original post offering a solution (from David C.) was "kind of" cross-platform because it used Adobe Reader which is available on most PCs and Macs, but not all - and David only seemed to want to show the user the document in a non-LC window, not manipulate it. Ah well, back to the grindstone...

Thanks for responding.

Graham

 On Tue, 18 Oct 2011 21:47:41 +0200, Francis Nugent Dixon <effendi at wanadoo.fr> 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
> 
> "Nothing should ever be done for the first time !"




More information about the use-livecode mailing list