public class PDFParser extends AbstractParser
This parser can process also encrypted PDF documents if the required
password is given as a part of the input metadata associated with a
document. If no password is given, then this parser will try decrypting
the document using the empty password that's often used with PDFs. If
the PDF contains any embedded documents (for example as part of a PDF
package) then this parser will use the EmbeddedDocumentExtractor
to handle them.
Modifier and Type | Field and Description |
---|---|
static String |
PASSWORD
Deprecated.
Supply a
PasswordProvider on the ParseContext instead |
Constructor and Description |
---|
PDFParser() |
Modifier and Type | Method and Description |
---|---|
boolean |
getEnableAutoSpace() |
boolean |
getExtractAnnotationText()
If true, text in annotations will be extracted.
|
boolean |
getSortByPosition() |
Set<MediaType> |
getSupportedTypes(ParseContext context)
Returns the set of media types supported by this parser when used
with the given parse context.
|
boolean |
getSuppressDuplicateOverlappingText() |
void |
parse(InputStream stream,
ContentHandler handler,
Metadata metadata,
ParseContext context)
Parses a document stream into a sequence of XHTML SAX events.
|
void |
setEnableAutoSpace(boolean v)
If true (the default), the parser should estimate
where spaces should be inserted between words.
|
void |
setExtractAnnotationText(boolean v)
If true (the default), text in annotations will be
extracted.
|
void |
setSortByPosition(boolean v)
If true, sort text tokens by their x/y position
before extracting text.
|
void |
setSuppressDuplicateOverlappingText(boolean v)
If true, the parser should try to remove duplicated
text over the same region.
|
parse
public static final String PASSWORD
public Set<MediaType> getSupportedTypes(ParseContext context)
Parser
context
- parse contextpublic void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException
Parser
The given document stream is consumed but not closed by this method. The responsibility to close the stream remains on the caller.
Information about the parsing context can be passed in the context parameter. See the parser implementations for the kinds of context information they expect.
stream
- the document stream (input)handler
- handler for the XHTML SAX events (output)metadata
- document metadata (input and output)context
- parse contextIOException
- if the document stream could not be readSAXException
- if the SAX events could not be processedTikaException
- if the document could not be parsedpublic void setEnableAutoSpace(boolean v)
public boolean getEnableAutoSpace()
#setEnableAutoSpace.
public void setExtractAnnotationText(boolean v)
public boolean getExtractAnnotationText()
public void setSuppressDuplicateOverlappingText(boolean v)
public boolean getSuppressDuplicateOverlappingText()
#setSuppressDuplicateOverlappingText.
public void setSortByPosition(boolean v)
public boolean getSortByPosition()
#setSortByPosition.
Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.