Now, PDF doc of objdictgen can be opened with acrobat reader on windows
authoretisserant
Fri, 08 Feb 2008 18:28:22 +0100
changeset 386 0f56a144ba5f
parent 385 fff25f16c923
child 387 6efc85c5493e
Now, PDF doc of objdictgen can be opened with acrobat reader on windows
objdictgen/doc_index/DS301_index.py
objdictgen/networkedit.py
objdictgen/objdictedit.py
--- a/objdictgen/doc_index/DS301_index.py	Fri Feb 08 14:52:48 2008 +0100
+++ b/objdictgen/doc_index/DS301_index.py	Fri Feb 08 18:28:22 2008 +0100
@@ -5,6 +5,23 @@
 
 DS301_PDF_INDEX = {0x1000: 86, 0x1001: 87, 0x1002: 87, 0x1003: 88, 0x1005: 89, 0x1006: 90, 0x1007: 90, 0x1008: 91, 0x1009: 91, 0x100A: 91, 0x100C: 92, 0x100D: 92, 0x1010: 92, 0x1011: 94, 0x1012: 97, 0x1013: 98, 0x1014: 98, 0x1015: 99, 0x1016: 100, 0x1017: 101, 0x1018: 101, 0x1020: 117, 0x1200: 103, 0x1201: 103, 0x1280: 105, 0x1400: 106, 0x1600: 109, 0x1800: 111, 0x1A00: 112}
 
+def get_acroversion():
+    " Return version of Adobe Acrobat executable or None"
+    import _winreg
+    adobesoft = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r'Software\Adobe')
+    for index in range(_winreg.QueryInfoKey(adobesoft)[0]):
+        key = _winreg.EnumKey(adobesoft, index)
+        if "acrobat" in key.lower():
+            acrokey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s' % key)
+            for index in range(_winreg.QueryInfoKey(acrokey)[0]):
+                numver = _winreg.EnumKey(acrokey, index)
+                try:
+                    res = _winreg.QueryValue(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Adobe\\%s\\%s\\InstallPath' % (key, numver))
+                    return res
+                except:
+                    pass
+    return None
+
 def OpenPDFDocIndex(index, cwd):
     if not os.path.isfile(os.path.join(cwd, "doc","301_v04000201.pdf")):
         return """No documentation file available.
@@ -12,12 +29,18 @@
     try:
         if index in DS301_PDF_INDEX:
             if wx.Platform == '__WXMSW__':
-                os.system("Reader %s -n %d &"%(os.path.join(cwd, "doc","301_v04000201.pdf"), DS301_PDF_INDEX[index]))
+                readerpath = get_acroversion()
+                readerexepath = os.path.join(readerpath,"AcroRd32.exe")
+                if(os.path.isfile(readerexepath)):
+                    os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", "/A", "page=%d=OpenActions" % DS301_PDF_INDEX[index], os.path.join(cwd, "doc","301_v04000201.pdf"))
             else:
                 os.system("xpdf -remote DS301 %s %d &"%(os.path.join(cwd, "doc","301_v04000201.pdf"), DS301_PDF_INDEX[index]))
         else:
             if wx.Platform == '__WXMSW__':
-                os.system("Reader %s &"%os.path.join(cwd, "doc","301_v04000201.pdf"))
+                readerpath = get_acroversion()
+                readerexepath = os.path.join(readerpath,"AcroRd32.exe")
+                if(os.path.isfile(readerexepath)):
+                    os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", os.path.join(cwd, "doc","301_v04000201.pdf"))
             else:
                 os.system("xpdf -remote DS301 %s &"%os.path.join(cwd, "doc","301_v04000201.pdf"))
         return True
--- a/objdictgen/networkedit.py	Fri Feb 08 14:52:48 2008 +0100
+++ b/objdictgen/networkedit.py	Fri Feb 08 18:28:22 2008 +0100
@@ -738,7 +738,13 @@
         
     def OnHelpCANFestivalMenu(self, event):
         #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600))
-        os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
+        if wx.Platform == '__WXMSW__':
+            readerpath = get_acroversion()
+            readerexepath = os.path.join(readerpath,"AcroRd32.exe")
+            if(os.path.isfile(readerexepath)):
+                os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", os.path.join(ScriptDirectory, "doc","manual_en.pdf"))
+        else:
+            os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
         event.Skip()
 
     def OnAboutMenu(self, event):
--- a/objdictgen/objdictedit.py	Fri Feb 08 14:52:48 2008 +0100
+++ b/objdictgen/objdictedit.py	Fri Feb 08 18:28:22 2008 +0100
@@ -392,7 +392,10 @@
     def OnHelpCANFestivalMenu(self, event):
         #self.OpenHtmlFrame("CAN Festival Reference", os.path.join(ScriptDirectory, "doc/canfestival.html"), wx.Size(1000, 600))
         if wx.Platform == '__WXMSW__':
-            os.system("Reader %s -n %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
+            readerpath = get_acroversion()
+            readerexepath = os.path.join(readerpath,"AcroRd32.exe")
+            if(os.path.isfile(readerexepath)):
+                os.spawnl(os.P_DETACH, readerexepath, "AcroRd32.exe", os.path.join(ScriptDirectory, "doc","manual_en.pdf"))
         else:
             os.system("xpdf -remote CANFESTIVAL %s %d &"%(os.path.join(ScriptDirectory, "doc/manual_en.pdf"),16))
         event.Skip()