/[suikacvs]/www/namazu/filter/pdf.pl
Suika

Contents of /www/namazu/filter/pdf.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Fri Nov 30 07:56:45 2001 UTC (22 years, 5 months ago) by wakaba
Branch: MAIN, wakaba
CVS Tags: initial, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain

1 #
2 # -*- Perl -*-
3 # $Id: pdf.pl,v 1.22 2001/01/04 01:57:58 baba Exp $
4 # Copyright (C) 1997-2000 Satoru Takabayashi ,
5 # 1999 NOKUBI Takatsugu All rights reserved.
6 # This is free software with ABSOLUTELY NO WARRANTY.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either versions 2, or (at your option)
11 # any later version.
12 #
13 # This program is distributed in the hope that it will be useful
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 # 02111-1307, USA
22 #
23 # This file must be encoded in EUC-JP encoding
24 #
25
26 package pdf;
27 use strict;
28 require 'util.pl';
29 require 'gfilter.pl';
30
31 my $pdfconvpath = undef;
32
33 sub mediatype() {
34 return ('application/pdf');
35 }
36
37 sub status() {
38 $pdfconvpath = util::checkcmd('pdftotext');
39 return 'yes' if (defined $pdfconvpath);
40 return 'no';
41 }
42
43 sub recursive() {
44 return 0;
45 }
46
47 sub pre_codeconv() {
48 return 0;
49 }
50
51 sub post_codeconv () {
52 return 1;
53 }
54
55 sub add_magic ($) {
56 return;
57 }
58
59 sub filter ($$$$$) {
60 my ($orig_cfile, $cont, $weighted_str, $headings, $fields)
61 = @_;
62 my $cfile = defined $orig_cfile ? $$orig_cfile : '';
63
64 my $tmpfile = util::tmpnam('NMZ.pdf');
65 my $tmpfile2 = util::tmpnam('NMZ.pdf2');
66
67 my $fh = util::efopen("> $tmpfile");
68 print $fh $$cont;
69 undef $fh;
70
71 if (util::islang("ja")) {
72 util::vprint("Processing pdf file ... (using '$pdfconvpath' in Japanese mode)\n");
73 system("$pdfconvpath -q -eucjp $tmpfile $tmpfile2");
74 } else {
75 util::vprint("Processing pdf file ... (using '$pdfconvpath')\n");
76 system("$pdfconvpath -q $tmpfile $tmpfile2");
77 }
78 unless (-e $tmpfile2) {
79 unlink $tmpfile;
80 unlink $tmpfile2;
81 return 'Unable to convert pdf file (maybe copying protection)';
82 }
83
84 $fh = util::efopen("< $tmpfile2");
85 $$cont = util::readfile($fh);
86 undef $fh;
87 unlink $tmpfile;
88 unlink $tmpfile2;
89
90 gfilter::line_adjust_filter($cont);
91 gfilter::line_adjust_filter($weighted_str);
92 gfilter::white_space_adjust_filter($cont);
93 $fields->{'title'} = gfilter::filename_to_title($cfile, $weighted_str)
94 unless $fields->{'title'};
95 gfilter::show_filter_debug_info($cont, $weighted_str,
96 $fields, $headings);
97 return undef;
98 }
99
100 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24