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
82 MessageBox MB_OK|MB_ICONEXCLAMATION "No PDF viewer is installed. \
83 Please install a PDF viewer such as Adobe Reader."
87 ${if} $Viewer == "AcroRd32.exe"
88 ${orif} $Viewer == "AcroRd64.exe"
89 ${orif} $Viewer == "Acrobat.exe"
91 # get the version of Acrobat - currenly not necessary
92 GetDLLVersion $ViewerFileName $R0 $R1
94 IntOp $R2 $R2 & 0x0000FFFF ; $R2 now contains major version
95 #IntOp $R3 $R0 & 0x0000FFFF ; $R3 now contains minor version
97 #IntOp $R4 $R4 & 0x0000FFFF ; $R4 now contains release
98 #IntOp $R5 $R1 & 0x0000FFFF ; $R5 now contains build
99 StrCpy $ViewerVersion $R2
101 # check if there is a windows open containing the PDF
102 ${if} $Viewer == "AcroRd32.exe"
103 ${orif} $Viewer == "AcroRd64.exe"
104 ${if} $ViewerVersion > 14
105 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat Reader DC"
107 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Reader"
109 ${elseif} $Viewer == "Acrobat.exe"
110 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat"
111 ${if} $ViewerHandle == "0"
112 FindWindow $ViewerHandle "" "$OriginalFileName - Adobe Acrobat Pro"
115 ${if} $ViewerHandle <> "0" # close the window
116 SendMessage $ViewerHandle 16 0 0
119 # Copy PDF to temporary file to allow LyX to overwrite the original
120 CopyFiles /SILENT $OriginalFile $PDFFile
123 ExecWait '"$ViewerFileName" "$PDFFile"'
127 # Another PDF viewer like GSView is used
128 # No need for special actions, just forward to ShellExecute
129 ExecShell open $OriginalFile