10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
# A plugin must define this procedure to do the job.
# side: left or right
# chi: An input channel for reading the original file.
# cho: An output channel for writing the processed file.
proc PreProcess {side chi cho} {
if {[info commands exec] eq ""} {
puts $cho "PDF plugin must be run with -pluginallow"
puts $cho "PDF plugin must be run with privilege to be able\
to execute pdftotext"
return 1
}
if {[auto_execok pdftotext] eq ""} {
set cands [auto_execok pdftotext]
lappend cands [file join $::WhoAmIFull pdftotext]
lappend cands [file join $::WhoAmIFull .. pdftotext]
lappend cands [file join $::WhoAmIFull .. .. pdftotext]
set found 0
foreach cand $cands {
if {[file exists $cand]} {
set found 1
break
}
if {[file exists $cand.exe]} {
set cand $cand.exe
set found 1
break
}
}
if {!$found} {
puts $cho "PDF plugin needs external tool 'pdftotext' to run"
return 1
}
if {[catch {llength $::Info}]} {
puts $cho "PDF plugin needs -plugininfo parameter to be a list"
return 1
}
if {[catch {exec pdftotext {*}$::Info - - <@ $chi >&@ $cho}]} {
if {[catch {exec $cand {*}$::Info - - <@ $chi >&@ $cho}]} {
puts $cho "**************************************"
puts $cho "PDF plugin got an error from pdftotext"
}
# Signal that the file after processing should be used both
# for comparison and for displaying.
return 1
|