.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mail::SpamAssassin::Plugin::ExtractText 3pm" .TH Mail::SpamAssassin::Plugin::ExtractText 3pm "2022-09-10" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ExtractText \- extracts text from documenmts. .SH "SYNOPSIS" .IX Header "SYNOPSIS" loadplugin Mail::SpamAssassin::Plugin::ExtractText .PP ifplugin Mail::SpamAssassin::Plugin::ExtractText .PP .Vb 2 \& extracttext_external pdftotext /usr/bin/pdftotext \-nopgbrk \-layout \-enc UTF\-8 {} \- \& extracttext_use pdftotext .pdf application/pdf \& \& # http://docx2txt.sourceforge.net \& extracttext_external docx2txt /usr/bin/docx2txt {} \- \& extracttext_use docx2txt .docx application/docx \& \& extracttext_external antiword /usr/bin/antiword \-t \-w 0 \-m UTF\-8.txt {} \& extracttext_use antiword .doc application/(?:vnd\e.?)?ms\-?word.* \& \& extracttext_external unrtf /usr/bin/unrtf \-\-nopict {} \& extracttext_use unrtf .doc .rtf application/rtf text/rtf \& \& extracttext_external odt2txt /usr/bin/odt2txt \-\-encoding=UTF\-8 {} \& extracttext_use odt2txt .odt .ott application/.*?opendocument.*text \& extracttext_use odt2txt .sdw .stw application/(?:x\-)?soffice application/(?:x\-)?starwriter \& \& extracttext_external tesseract {OMP_THREAD_LIMIT=1} /usr/bin/tesseract \-c page_separator= {} \- \& extracttext_use tesseract .jpg .png .bmp .tif .tiff image/(?:jpeg|png|x\-ms\-bmp|tiff) \& \& add_header all ExtractText\-Flags _EXTRACTTEXTFLAGS_ \& header PDF_NO_TEXT X\-ExtractText\-Flags =~ /\ebpdftotext_NoText\eb/ \& describe PDF_NO_TEXT PDF without text \& score PDF_NO_TEXT 0.001 \& \& header DOC_NO_TEXT X\-ExtractText\-Flags =~ /\eb(?:antiword|openxml|unrtf|odt2txt)_NoText\eb/ \& describe DOC_NO_TEXT Document without text \& score DOC_NO_TEXT 0.001 \& \& header EXTRACTTEXT exists:X\-ExtractText\-Flags \& describe EXTRACTTEXT Email processed by extracttext plugin \& score EXTRACTTEXT 0.001 .Ve .PP endif .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module uses external tools to extract text from message parts, and then sets the text as the rendered part. External tool must output plain text, not \s-1HTML\s0 or other non-textual result. .PP How to extract text is completely configurable, and based on \&\s-1MIME\s0 part type and file name. .SH "CONFIGURATION" .IX Header "CONFIGURATION" All configuration lines in user_prefs files will be ignored. .IP "extracttext_maxparts (default: 10)" 4 .IX Item "extracttext_maxparts (default: 10)" Configure the maximum mime parts number to analyze, a value of 0 means all mime parts will be analyzed .IP "extracttext_timeout (default: 5 10)" 4 .IX Item "extracttext_timeout (default: 5 10)" Configure the timeout in seconds of external tool checks, per attachment. .Sp Second argument speficies maximum total time for all checks. .SS "Tools" .IX Subsection "Tools" .IP "extracttext_use" 4 .IX Item "extracttext_use" Specifies what tool to use for what message parts. .Sp The general syntax is .Sp extracttext_use \f(CW\*(C`name\*(C'\fR \f(CW\*(C`specifiers\*(C'\fR .IP "name" 4 .IX Item "name" the internal name of a tool. .IP "specifiers" 4 .IX Item "specifiers" File extension and regular expressions for file names and \s-1MIME\s0 types. The regular expressions are anchored to beginning and end. .PP \fIExamples\fR .IX Subsection "Examples" .PP .Vb 4 \& extracttext_use antiword .doc application/(?:vnd\e.?)?ms\-?word.* \& extracttext_use openxml .docx .dotx .dotm application/(?:vnd\e.?)openxml.*?word.* \& extracttext_use openxml .doc .dot application/(?:vnd\e.?)?ms\-?word.* \& extracttext_use unrtf .doc .rtf application/rtf text/rtf .Ve .IP "extracttext_external" 4 .IX Item "extracttext_external" Defines an external tool. The tool must read a document on standard input or from a file and write text to standard output. .Sp The special keyword \*(L"{}\*(R" will be substituted at runtime with the temporary filename to be scanned by the external tool. .Sp Environment variables can be defined with \*(L"{KEY=VALUE}\*(R", these strings will be removed from commandline. .Sp It is required that commandline used outputs result directly to \s-1STDOUT.\s0 .Sp The general syntax is .Sp extracttext_external \f(CW\*(C`name\*(C'\fR \f(CW\*(C`command\*(C'\fR \f(CW\*(C`parameters\*(C'\fR .IP "name" 4 .IX Item "name" The internal name of this tool. .IP "command" 4 .IX Item "command" The full path to the external command to run. .IP "parameters" 4 .IX Item "parameters" Parameters for the external command. The temporary file name containing the document will be automatically added as last parameter. .PP \fIExamples\fR .IX Subsection "Examples" .PP .Vb 3 \& extracttext_external antiword /usr/bin/antiword \-t \-w 0 \-m UTF\-8.txt {} \- \& extracttext_external unrtf /usr/bin/unrtf \-\-nopict {} \& extracttext_external odt2txt /usr/bin/odt2txt \-\-encoding=UTF\-8 {} .Ve .SS "Metadata" .IX Subsection "Metadata" The plugin adds some pseudo headers to the message. These headers are seen by the bayes system, and can be used in normal SpamAssassin rules. .PP The headers are also available as template tags as noted below. .PP \fIExample\fR .IX Subsection "Example" .PP The fictional example headers below are based on a message containing this: .IP "1 A perfectly normal \s-1PDF.\s0" 4 .IX Item "1 A perfectly normal PDF." .PD 0 .IP "2 An OpenXML document with a word document inside. Neither Office document contains text." 4 .IX Item "2 An OpenXML document with a word document inside. Neither Office document contains text." .PD .PP \fIHeaders\fR .IX Subsection "Headers" .IP "X\-ExtractText-Chars" 4 .IX Item "X-ExtractText-Chars" Tag: _EXTRACTTEXTCHARS_ .Sp Contains a count of characters that were extracted. .Sp X\-ExtractText-Chars: 10970 .IP "X\-ExtractText-Words" 4 .IX Item "X-ExtractText-Words" Tag: _EXTRACTTEXTWORDS_ .Sp Contains a count of \*(L"words\*(R" that were extracted. .Sp X\-ExtractText-Chars: 1599 .IP "X\-ExtractText-Tools" 4 .IX Item "X-ExtractText-Tools" Tag: _EXTRACTTEXTTOOLS_ .Sp Contains chains of tools used for extraction. .Sp X\-ExtractText-Tools: pdftotext openxml_antiword .IP "X\-ExtractText-Types" 4 .IX Item "X-ExtractText-Types" Tag: _EXTRACTTEXTTYPES_ .Sp Contains chains of \s-1MIME\s0 types for parts found during extraction. .Sp X\-ExtractText-Types: application/pdf; application/vnd.openxmlformats\-officedocument.wordprocessingml.document, application/ms\-word .IP "X\-ExtractText-Extensions" 4 .IX Item "X-ExtractText-Extensions" Tag: _EXTRACTTEXTEXTENSIONS_ .Sp Contains chains of canonicalized file extensions for parts found during extraction. .Sp X\-ExtractText-Extensions: pdf docx .IP "X\-ExtractText-Flags" 4 .IX Item "X-ExtractText-Flags" Tag: _EXTRACTTEXTFLAGS_ .Sp Contains notes from the plugin. .Sp X\-ExtractText-Flags: openxml_NoText .PP \fIRules\fR .IX Subsection "Rules" .PP Example: .PP .Vb 2 \& header PDF_NO_TEXT X\-ExtractText\-Flags =~ /\ebpdftotext_Notext\eb/ \& describe PDF_NO_TEXT PDF without text .Ve