Debian Codegraph @

contrib/doc2html/DETAILS

raw
1 INTRODUCTION
2 ============
3
4 This DETAILS file accompanies doc2html version 3.0.1.
5
6 Read this file for instructions on the installation and use of the
7 doc2html scripts.
8
9 The set of files is:
10
11 DETAILS - this file
12 doc2html.pl - the main Perl script
13 doc2html.cfg - configuration file for use with wp2html
14 doc2html.sty - style file for use with wp2html
15 pdf2html.pl - Perl script for converting PDF files to HTML
16 swf2html.pl - Perl script for extracting links from Shockwave flash files.
17 README - brief description
18
19 doc2html.pl is a Perl5 script for use as an external converter with
20 htdig 3.1.4 or later. It takes as input the name of a file containing a
21 document in a number of possible formats and its MIME type. It uses
22 the appropriate conversion utility to convert it to HTML on standard
23 output.
24
25 doc2html.pl was designed to be easily adapted to use whatever conversion
26 utilities are available, and although it has been written around the
27 "wp2html" utility, it does not require wp2html to function.
28
29 NOTE: version 3.0.1 has only been tested on Unix.
30
31 pdf2html.pl is a Perl script which uses a pair of utilities (pdfinfo and
32 pdf2text) to extract information and text from an Adobe PDF file and
33 write HTML output. It can be called directly from htdig, but you are
34 recommended to call it via doc2html.pl.
35
36 swf2html.pl is a Perl script which calls a utility (swfparse) and
37 outputs HTML containing links to the URL's found in a Shockwave flash
38 file. It can be called directly from htdig, but you are recommended to
39 call it via doc2html.pl.
40
41
42 ABOUT DOC2HTML.PL
43 =================
44
45 doc2html.pl is essentially a wrapper script, and is itself only capable
46 of reading plain text files. It requires the utility programs described
47 below to work properly.
48
49 doc2html.pl was written by David Adams <[email protected]>, it is
50 based on conv_doc.pl written by Gilles Detillieux <[email protected]>.
51 This in turn was based on the parse_word_doc.pl script, written by
52 Jesse op den Brouw <[email protected]>.
53
54 doc2html.pl makes up to three attempts to read a file. It first tries
55 utilities which convert directly into HTML. If one is not found, or no
56 output is produced, it then tries utilities which output plain text. If
57 none is found, and the file is not of a type known to be unconvertable,
58 then doc2html.pl attempts to read the file itself, stripping out any
59 control characters.
60
61 doc2html.pl is written to be flexible and easy to adapt to whatever
62 conversion utilites are available. New conversion utilities may be
63 added simply by making additions to routine 'store_methods', with no
64 other changes being necessary. The existing lines in store_methods
65 should provide sufficient examples on how to add more converters. Note
66 that converters which produce HTML are entered differently to those that
67 produce plain text.
68
69 htdig provides three arguments which are read by doc2html.pl:
70
71 1) the name of a temporary file containing a copy of the
72 document to be converted.
73
74 2) the MIME type of the document.
75
76 3) the URL of the document (which is used in generating the
77 title in the output).
78
79 The test for document type uses both the MIME-type passed as second
80 argument and the "Magic number" of the file.
81
82
83 INSTALLATION
84 ============
85
86 Installation requires that you acquire, compile and install the utilities
87 you need to do the conversions. Those already setup in the Perl scripts are
88 described below.
89
90 If you don't have Perl module Sys::AlarmCall installed, then consider
91 installing it, see section "TIMEOUT" below.
92
93 You may need to change the first line of each script to the location of
94 Perl on your system.
95
96 Edit doc2html.pl to include the full pathname of each utility you have
97 installed. For example:
98
99 my $WP2HTML = '/opt/local/wp2html-3.2/bin/wp2html';
100
101 If you don't have a particular utility then leave its location as a null
102 string.
103
104 Then place doc2html.pl and the other scripts where htdig can access them.
105
106 If you are going to convert PDF files then you will need to edit pdf2html.pl
107 and include its full path name in doc2html.pl.
108
109 If you are going to extract links from Shockwave flash files then you will
110 need to edit swf2html.pl and include its full path name in doc2html.pl.
111
112 Edit the htdig.conf configuration file to use the script, as in this example:
113
114 external_parsers: application/rtf->text/html /usr/local/scripts/doc2html.pl \
115 text/rtf->text/html /usr/local/scripts/doc2html.pl \
116 application/pdf->text/html /usr/local/scripts/doc2html.pl \
117 application/postscript->text/html /usr/local/scripts/doc2html.pl \
118 application/msword->text/html /usr/local/scripts/doc2html.pl \
119 application/Wordperfect5.1->text/html /usr/local/scripts/doc2html.pl \
120 application/msexcel->text/html /usr/local/scripts/doc2html.pl \
121 application/vnd.ms-excel->text/html /usr/local/scripts/doc2html.pl \
122 application/vnd.ms-powerpoint->text/html /usr/local/scripts/doc2html.pl \
123 application/x-shockwave-flash->text/html /usr/local/scripts/doc2html.pl \
124 application/x-shockwave-flash2-preview->text/html /usr/local/scripts/doc2html.pl
125
126 If you are using wp2html then place the files doc2html.cfg and doc2html.sty in the
127 wp2html library directory.
128
129
130 UTILITY WP2HTML
131 ===============
132
133 Obtain wp2html from http://www.res.bbsrc.ac.uk/wp2html/
134
135 Note that wp2html is not free; its author charges a small fee for
136 "registration". Various pre-compiled versions and the source code are
137 available, together with extensive documentation. Upgrades are
138 available at no further charge.
139
140 wp2html converts WordPerfect documents (5.1 and later) to HTML.
141 Versions 3.2 and later will also convert Word7 and Word97 documents to
142 HTML. A feature of wp2html which doc2html.pl exploits is that the -q
143 option will result in either good HTML or no output at all.
144
145 wp2html is very flexible in the output it creates. The two files,
146 doc2html.cfg and doc2html.sty, should be placed in the wp2html library
147 directory along with the .cfg and .sty files supplied with wp2html.
148
149 Edit the line in doc2html.pl:
150
151 my $WP2HTML = '';
152
153 to set $WP2HTML to the full pathname of wp2html.
154
155 wp2html will look for the title in a document, and if it is found then
156 output it in <TITLE>....</TITLE> markup. If a title is not found
157 then it defaults to the file name in square brackets.
158
159 If wp2html is unable to convert a document, or is not installed,
160 then doc2html.pl can use the "catdoc" or "catwpd" utilities instead.
161
162
163 UTILITY CATDOC
164 ==============
165
166 Obtain catdoc from http://www.ice.ru/~vitus/catdoc/, it is available
167 under the terms of the Gnu Public License.
168
169 Edit the line in doc2html.pl:
170
171 my $CATDOC = '';
172
173 to set the variables to the full pathname of catdoc. You might want
174 to use a different version of catdoc for Word2 documents or for MAC Word
175 files.
176
177 catdoc converts MS Word6, Word7, etc., documents to plain text. The
178 latest beta version is also able to convert Word2 documents. catdoc
179 also produces a certaint amount of "garbage" as well as the text of the
180 document. The -b option improves the likelihood that catdoc will
181 extract all the text from the document, but at the expense of increasing
182 the garbage as well. doc2html.pl removes some non-printing characters
183 to minimise the garbage. If a later version of catdoc than 0.91.4 is
184 obtained then the use of the -b option should be reviewed.
185
186
187 UTILITY CATWPD
188 ==============
189
190 Obtain catwpd from the contribs section of the Ht://Dig web site where
191 you obtained doc2html. It extracts words from some versions of WordPerfect
192 files. You won't need it if you buy the superior wp2html.
193
194 If you do use it, then edit the line in doc2html.pl:
195
196 my $CATWPD = '';
197
198 to set the variables to the full pathname of catwpd.
199
200
201 UTILITY PPTHTML
202 ===============
203
204 obtain ppthtml from http://www.xlhtml.org, where it is bundled in with
205 xlhtml.
206
207 In doc2html.pl, edit the line:
208
209 my $PPT2HTML = '';
210
211 to set $PPT2HTML to the full pathname of ppthtml.
212
213 ppthtml converts Microsoft Powerpoint files into HTML. It uses the input
214 filename as the title. doc2html.pl replaces this with the original
215 filename from the URL in square brackets.
216
217
218 UTILITY XLHTML
219 ==============
220
221 Obtain xlhtml from http://www.xlhtml.org
222
223 In doc2html.pl, edit the line:
224
225 my $XLS2HTML = '';
226
227 to set $XLS2HTML to the full pathname of xlhtml.
228
229 xlhtml converts Microsoft Excel spreadsheets into HTML. It uses the input
230 filename as the title. doc2html.pl replaces this with the original
231 filename from the URL in square brackets.
232
233 The present version of xlHtml (0.4) writes HTML output, but does not
234 mark up hyperlinks in .xls files as links in its output.
235
236 An alternative to xlHtml is xls2csv, see below.
237
238
239 UTILITY RTF2HTML
240 ================
241
242 Obtain rtf2html from http://www.ice.ru/~vitus/catdoc/
243
244 In doc2html.pl, edit the line:
245
246 my $RTF2HTML = '';
247
248 to set $RTF2HTML to the full pathname of rtf2html.
249
250 rtf2html converts Rich Text Font documents into HTML. It uses the input
251 filename as the title, doc2html.pl replaces this with the original
252 filename from the URL within square brackets.
253
254
255 UTILITY PS2ASCII
256 ================
257
258 Ps2ascii is a PostScript to text converter.
259
260 In doc2html.pl, edit the line:
261
262 my $CATPS = '';
263
264 to the correct full pathname of ps2ascii.
265
266 ps2ascii comes with ghostscript 3.33 (or later) package, which is
267 pre-installed on many Unix systems. Commonly, it is a Bourne-shell
268 script which invokes "gs", the Ghostscript binary. doc2html.pl has
269 provision for adding the location of gs to the search path.
270
271
272 UTILITY PDFTOTEXT
273 =================
274
275 pdftotext converts Adobe PDF files to text. pdfinfo is a tool which
276 displays information about the document, and is used to obtain its
277 title, etc. Get them from the xpdf package at
278 http://www.foolabs.com/xpdf/
279
280 In script pdf2html.pl, change the lines:
281
282 my $PDFTOTEXT = "/... .../pdftotext";
283 my $PDFINFO = "/... .../pdfinfo";
284
285 to the correct full pathnames.
286
287 Edit doc2html.pl to include the full pathname of the pdf2html.pl script.
288
289 pdf2text may fail to convert PDF documents which have been truncated
290 because htdig has max_doc_size set to smaller than the documents full
291 size. Some PDF documents do not allow text to be extracted.
292
293
294 UTILITY CATXLS
295 ==============
296
297 The Excel to .csv converter, xls2csv, is included with recent versions of
298 catdoc. This is an alternative to xlhtml (see above).
299
300 Edit the line:
301
302 my $CATXLS = '';
303
304 to the full pathname of xls2csv.
305
306 Xls2csv translates Excel spread sheets into comma-separated data.
307
308
309 UTILITY SWFPARSE
310 ================
311
312 swfparse (aka swfdump) extracts information from Shockwave flash files,
313 and can be obtained from the contribs section of the Ht://Dig web site,
314 where you obtained doc2html.
315
316 Perl script swf2html.pl calls swfparse and writes HTML output containing
317 links to the URLs found in the Shockwave file. It does NOT extract text
318 from the file.
319
320 In script swf2html.pl, change the line:
321
322 my $SWFPARSE = "/... .../swfdump";
323
324 to the full pathname.
325
326 Edit doc2html.pl to include the full pathname of the swf2html.pl script.
327
328
329 LOGGING
330 =======
331
332 Output of logging information and error messages is controlled by the
333 environmental variable DOC2HTML_LOG, which may be set in the rundig
334 script. If it is not set then only error messages output by doc2html.pl
335 and by the conversion utilities it calls are returned to htdig and will
336 appear in its STDOUT. If DOC2HTML_LOG is set to a filename, then
337 doc2html.pl appends logging information and any error messages to the
338 file. If DOC2HTML_LOG is set but blank, or the file cannot be opened
339 for writing, logging information and error messages are passed back to
340 htdig and will appear its STDOUT.
341
342 In doc2html.pl, the variables $Emark and $EEmark, set in subroutine init,
343 are used to highlight error messages.
344
345 The number of lines of STDERR output from a utility which is logged or
346 passed back to htdig is controlled by the variable $Maxerr set in
347 routine "init" of doc2html.pl. This is provided in order to curb the
348 large number of error messages which some utilities can produce from
349 processing a single file.
350
351
352 TIMEOUT
353 =======
354
355 If possible, install Perl module Sys::AlarmCall, obtainable from CPAN if
356 you don't already have it. This module is used by doc2html.pl to
357 terminate a utility if it takes too long to finish. The line in
358 doc2html.pl:
359
360 $Time = 60; # allow 60 seconds for external utility to complete
361
362 may be altered to suit.
363
364
365 LIMITING INPUT AND OUTPUT
366 =========================
367
368 The environmental variable DOC2HTML_IP_LIMIT may be set in the rundig
369 script to limit the size of the file which doc2html.pl will attempt to
370 convert. The default value is 20000000. Doc2html.pl will return no
371 output to htdig if the file size is equal to or greater than this size.
372
373 You are recommended to set DOC2HTML_IP_LIMIT to the same as the
374 "max_doc_size" parameter in the htdig configuration file. Then no
375 attempt wil be made to extract text from files which have been truncated
376 by htdig. It is not possible to extract any text from .PDF files, for
377 example, if they have been truncated.
378
379 The environmental variable DOC2HTML_OP_LIMIT may be set in the rundig
380 script to limit the output sent back to htdig by a single call to
381 doc2html.pl. The default value is 10000000. Doc2html.pl will stop
382 returning output to htdig once the DOC2HTML_OP_LIMIT has been reached.
383 This is precaution against the unlikely event of a conversion utility
384 returning disproportionately large amounts of data.
385
386
387 CONTACT
388 =======
389
390 Any queries regarding doc2html are best sent to the mailing list
391 [email protected]
392
393 The author can be emailed at [email protected]
394
395 David Adams
396 Information Systems Services
397 University of Southampton
398
399 27-November-2002