Howto open PDF with Adobe Acrobat or Reader using DDE

This page provides an example of how to open PDF with Adobe [4 ] Acrobat or Adobe Acrobat Reader using the DDE package. For more information see DeveloperFAQ.pdf [3 ], IACOverview.pdf [2 ] and IACReference.pdf [1 ].

Alexander Schöpe


See also


 package require dde

 if {[catch {registry get HKEY_CLASSES_ROOT\\acrobat\\shell\\open\\command {}} acrobat]} {
   puts stderr "registry: $acrobat"
   exit 1
 }
 set acrobat [string range $acrobat 0 [string first " /u" $acrobat]]

 if {[catch {registry get HKEY_CLASSES_ROOT\\acrobat\\shell\\open\\ddeexec\\application {}} service]} {
   puts stderr "registry: $service"
   exit 1
 }
 if {[catch {registry get HKEY_CLASSES_ROOT\\acrobat\\shell\\open\\ddeexec\\topic {}} topic]} {
   puts stderr "registry: $topic"
   exit 1
 }

 if {[dde services $service $topic] == ""} {
   exec $acrobat &
 }

 dde execute $service $topic {[FileOpen("C:\IACReference.pdf")]}

jnc Jan-12-2010: Acrobat DDE reference (which includes tags such as "also supported in Acro Reader" is available at: http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/iac/IACReference.pdf

One thing that caused delay in me understanding the DDE interface is that after you call the DDE function FileOpen, to work with the document (for instance, calling DocGoTo()) you must call DocOpen(). FileOpen tells Acro Reader to open the document but that does not enable you to then control the document. DocOpen() will make the document then available for DDE control.