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.
16 #--------------------------------
21 Icon "..\packaging\icons\lyx.ico"
24 #--------------------------------
25 # Windows Vista (and later) settings
27 RequestExecutionLevel user
29 #--------------------------------
45 #--------------------------------
48 !macro SystemCall STACK
50 # Call a Windows API function
53 CallInstDLL "$EXEDIR\System.dll" Call
57 !macro HideConsole COMMAND_LINE
59 # Run an application and hide console output
61 Push `${COMMAND_LINE}`
62 CallInstDLL "$EXEDIR\Console.dll" Exec
65 ${If} $RunAppReturn == "error"
66 MessageBox MB_OK|MB_ICONSTOP "Error opening PDF file $PDFFile."
71 #--------------------------------
74 Section "View PDF file"
76 InitPluginsDir # Temporary directory for PDF file
78 # Command line parameters
79 ${GetParameters} $OriginalFile
82 StrCpy $Character $OriginalFile 1
83 ${If} $Character == '"'
84 StrCpy $OriginalFile $OriginalFile "" 1
86 StrCpy $Character $OriginalFile 1 -1
87 ${If} $Character == '"'
88 StrCpy $OriginalFile $OriginalFile -1
91 GetFullPathName $OriginalFile $OriginalFile
92 ${GetFileName} $OriginalFile $OriginalFileName
93 ${GetParent} $OriginalFile $OriginalDir # tmpbuf
94 ${GetParent} $OriginalDir $OriginalDir # tmpdir
96 SetOutPath $TEMP # The LyX tmpbuf should not be locked
98 StrCpy $PDFFile $PLUGINSDIR\$OriginalFileName
100 # Check whether the file will be opened with Adobe Reader or Adobe Acrobat
101 !insertmacro SystemCall "shell32::FindExecutable(t '$OriginalFile', t '', t .s)"
103 ${GetFileName} $ViewerFileName $Viewer
106 MessageBox MB_OK|MB_ICONEXCLAMATION "No PDF viewer is installed. \
107 Please install a PDF viewer such as Adobe Reader."
111 ${if} $Viewer == "AcroRd32.exe"
112 ${orif} $Viewer == "AcroRd64.exe"
113 ${orif} $Viewer == "Acrobat.exe"
115 # get the version of Acrobat - currenly not necessary
116 GetDLLVersion $ViewerFileName $R0 $R1
118 IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
119 #IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
121 #IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
122 #IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
123 StrCpy $ViewerVersion $R2
125 # check if there is a windows open containing the PDF
126 ${if} $Viewer == "AcroRd32.exe"
127 ${orif} $Viewer == "AcroRd64.exe"
128 ${if} $ViewerVersion > 14
129 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat Reader DC"
131 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Reader"
133 ${elseif} $Viewer == "Acrobat.exe"
134 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat"
135 ${if} $ViewerHandle == "0"
136 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat Pro"
139 ${if} $ViewerHandle <> "0" # close the window
140 SendMessage $ViewerHandle 16 0 0
143 # Copy PDF to temporary file to allow LyX to overwrite the original
144 CopyFiles /SILENT $OriginalFile $PDFFile
147 !insertmacro HideConsole '"$ViewerFileName" "$PDFFile"'
151 # Another PDF viewer like GSView is used
152 # No need for special actions, just forward to ShellExecute
153 ExecShell open $OriginalFile