blob: d3e429e12ec501c24cfa44e504ae8b9ad5653cf2 (
plain)
1
2
3
4
5
6
7
8
9
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
54
55
56
57
58
59
|
$NetBSD: patch-aq,v 1.1 2003/05/25 14:12:13 taca Exp $
--- filter/pdf.pl.orig 2002-07-30 15:03:08.000000000 +0900
+++ filter/pdf.pl
@@ -31,7 +31,9 @@ require 'gfilter.pl';
my $pdfconvpath = undef;
my $pdfinfopath = undef;
my $pdfconvver = 0;
+my $pdfinfover = 0;
my $pdfconvarg = '';
+my $pdfinfoarg = '';
sub mediatype() {
return ('application/pdf');
@@ -52,6 +54,19 @@ sub status() {
$pdfconvarg = '-eucjp';
}
}
+ if (defined $pdfinfopath) {
+ my $ret = `$pdfinfopath 2>&1`;
+ if ($ret =~ /^pdfinfo\s+version\s+([0-9]+\.[0-9]+)/) {
+ $pdfinfover = $1;
+ }
+ if (util::islang("ja")) {
+ if ($pdfinfover >= 2.02) {
+ $pdfinfoarg = '-enc EUC-JP';
+ } else {
+ $pdfinfoarg = '';
+ }
+ }
+ }
return 'yes';
}
return 'no';
@@ -116,7 +131,7 @@ sub filter ($$$$$) {
# system("$pdfinfopath $tmpfile > $tmpfile3");
open(SAVEOUT, ">&STDOUT");
open(STDOUT, ">$tmpfile3");
- system("$pdfinfopath $tmpfile");
+ system("$pdfinfopath $pdfinfoarg $tmpfile");
open(STDOUT, ">&SAVEOUT");
my $fh = util::efopen("< $tmpfile3");
my $cont2 = util::readfile($fh);
@@ -124,9 +139,15 @@ sub filter ($$$$$) {
unlink($tmpfile3);
if ($cont2 =~ /Title: (.*)/) { # or /Subject: (.*)/
$fields->{'title'} = $1;
+ if ($fields->{'title'} =~ /<unicode>/) {
+ $fields->{'title'} = undef;
+ }
}
if ($cont2 =~ /Author: (.*)/) {
$fields->{'author'} = $1;
+ if ($fields->{'author'} =~ /<unicode>/) {
+ $fields->{'author'} = undef;
+ }
}
}
|