3 Windows PDF view helper
4 Author: Uwe Stöhr and Joost Verburg
6 This will be installed as pdfview.exe.
8 The application will launch the default PDF viewer to display the PDF file,
9 but works around the file locking problems of Adobe Reader and Acrobat.
18 #--------------------------------
23 Icon "..\packaging\icons\lyx.ico"
26 #--------------------------------
27 # Windows Vista (and later) settings
29 RequestExecutionLevel user
31 #--------------------------------
45 #--------------------------------
48 Section "View PDF file"
50 InitPluginsDir # Temporary directory for PDF file
52 # Command line parameters
53 ${GetParameters} $OriginalFileName
56 StrCpy $Character $OriginalFileName 1
57 ${If} $Character == '"'
58 StrCpy $OriginalFileName $OriginalFileName "" 1
60 StrCpy $Character $OriginalFileName 1 -1
61 ${If} $Character == '"'
62 StrCpy $OriginalFileName $OriginalFileName -1
65 GetFullPathName $OriginalFile $OriginalFileName
67 SetOutPath $TEMP # The LyX tmpbuf should not be locked
69 StrCpy $PDFFile $PLUGINSDIR\$OriginalFileName
71 # Check whether the file will be opened with Adobe Reader or Adobe Acrobat
73 FileOpen $R0 "$PLUGINSDIR\a.pdf" "w" #create a temp pdf file with a simple name
76 #find stadard executable for "a.pdf", writes result in $0 (".r0" below)
77 System::Call "shell32::FindExecutable(t '$PLUGINSDIR\a.pdf', t '', t .r0)"
78 StrCpy $ViewerFileName $0
79 ${GetFileName} $ViewerFileName $Viewer
81 ${if} $Viewer == "AcroRd32.exe"
82 ${orif} $Viewer == "AcroRd64.exe"
83 ${orif} $Viewer == "Acrobat.exe"
85 # get the version of Acrobat - currenly not necessary
86 GetDLLVersion $ViewerFileName $R0 $R1
88 IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
89 #IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
91 #IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
92 #IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
93 StrCpy $ViewerVersion $R2
95 # check if there is a windows open containing the PDF
96 ${if} $Viewer == "AcroRd32.exe"
97 ${orif} $Viewer == "AcroRd64.exe"
98 ${if} $ViewerVersion > 14
99 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat Reader DC"
101 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Reader"
103 ${elseif} $Viewer == "Acrobat.exe"
104 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat"
105 ${if} $ViewerHandle == "0"
106 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat Pro"
109 ${if} $ViewerHandle <> "0" # close the window
110 SendMessage $ViewerHandle 16 0 0
113 # Copy PDF to temporary file to allow LyX to overwrite the original
114 CopyFiles /SILENT $OriginalFile $PDFFile
117 ExecWait '"$ViewerFileName" "$PDFFile"'
121 # Another PDF viewer like GSView is used
122 # No need for special actions, just forward to ShellExecute
123 ExecShell open $OriginalFile