pdf files

Peter Reid preid at reidit.co.uk
Mon May 13 04:25:00 EDT 2002


>Mike,
>
>The following was posted by Peter Reid on the Runtime Revolution site a
>while ago... have fun:
>snip...

Since posting my previous scripts on the RunRev list, I have done 
more work on a general solution and come up with the following:

   -- the following should be executed during preOpenStack or openStack:
   global gAcrobatReader
   if "Mac" is in the platform then
     -- don't need path of Mac Acrobat Reader:
     put empty into gAcrobatReader
   else
     -- get path of Win Acrobat Reader from registry:
     put 
queryRegistry("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App 
Paths\" \
         & cWinAcrobatReader & "\Path") into regEntry
     if regentry is not empty then
       -- found specific Reader entry:
       put regEntry & "\" & cWinAcrobatReader into gAcrobatReader
     else
       -- if no entry for Reader try general, i.e. full Acrobat entry:
       put word 1 to -2 of \
 
queryRegistry("HKEY_CLASSES_ROOT\AcroExch.Document\shell\open\command\") 
\
           into gAcrobatReader
     end if
   end if

on showAcrobatFile pdfFile
   -- open Acrobat file inside Reader/full Acrobat:
   global gPlatform, gAcrobatReader, gAppleScript
   if "Win" is in gPlatform then  -- use default Win Acrobat Reader:
     kill process gAcrobatReader    -- close any currently running 
Acrobat Reader
     wait 15 ticks
     launch pdfFile with gAcrobatReader
   else  -- MacOS - get Finder to open Acrobat file:
     put "tell application " & quote & "Finder" & quote & return & \
         "open file " & quote & char 2 to -1 of pdfFile & quote & return & \
         "end tell" & return into theAppleScript
     replace "/" with ":" in theAppleScript
     do theAppleScript as AppleScript
   end if
end showAcrobatFile

HOW IT WORKS
------------
For Windows:
- The first section of script tries to use the Reader in the case 
where the Windows user also has the full Acrobat system.  This is 
because the Reader opens more quickly and means the user is less 
likely to accidently edit the PDF file!
- We need to kill any current running copy of the Acrobat Reader to 
avoid lots of multiple copies running as several PDF files are opened.
- simply launch the sole copy of Reader with the required PDF file

For Mac:
- Just open whatever is the default viewer for Acrobat files using 
AppleScript.  This might open the Reader or full Acrobat if 
installed.  It's not possible to make the distinction that we can 
with Windows.
- no danger of multiple copies of a program running with the Mac, so 
no need to kill any previous running copy of Acrobat
- simply run the default Acrobat viewer with the specified PDF file 
using AppleScript

Note:
Previous versions of RunRev had a problem with launched apps exiting 
when the launching program (your Rev/MC app) quits.  The latest 
version of RunRev (v1.1.1) and presumably mc, doesn't seem to have 
this problem.  Therefore I found I didn't need the more complex 
solution I posted previously.

TESTING
-------
The above solution has been tested and works well with RunRev 1.1.1 
for various Mac OS, Win 98SE and Win XP Pro.  Whilst not tested using 
MetaCard, I'd guess it should work with the latest full release 
version of mc (i.e. the same one currently at the heart of RunRev 
1.1.1)

Cheers

Peter
-- 
Peter Reid
Reid-IT Limited, Loughborough, Leics., UK
Tel: +44 (0)1509 268843 Fax: +44 (0)870 052 7576
E-mail: preid at reidit.co.uk
Web: http://www.reidit.co.uk



More information about the metacard mailing list