public class PDFParser extends AbstractParser implements Initializable
EmbeddedDocumentExtractor
to handle them.
As of Tika 1.6, it is possible to extract inline images with
the EmbeddedDocumentExtractor
as if they were regular
attachments. By default, this feature is turned off because of
the potentially enormous number and size of inline images. To
turn this feature on, see
PDFParserConfig.setExtractInlineImages(boolean)
.
Please note that tables are not stored as entities within PDFs. It
takes significant computation to identify and then correctly extract
tables from PDFs. As of this writing, the PDFParser
extracts
text within tables, but it does not compute table cell boundaries or
table row boundaries. Please see
tabula for one project that
tries to maintain the structure of tables represented in PDFs.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PASSWORD
Deprecated.
Supply a
PasswordProvider on the ParseContext instead |
Constructor and Description |
---|
PDFParser() |
Modifier and Type | Method and Description |
---|---|
void |
checkInitialization(InitializableProblemHandler handler) |
boolean |
getEnableAutoSpace()
Deprecated.
|
boolean |
getExtractAnnotationText()
Deprecated.
|
PDFParserConfig |
getPDFParserConfig() |
boolean |
getSortByPosition()
Deprecated.
|
java.util.Set<MediaType> |
getSupportedTypes(ParseContext context)
Returns the set of media types supported by this parser when used
with the given parse context.
|
boolean |
getSuppressDuplicateOverlappingText()
Deprecated.
|
void |
initialize(java.util.Map<java.lang.String,Param> params)
This is a no-op.
|
void |
parse(java.io.InputStream stream,
org.xml.sax.ContentHandler handler,
Metadata metadata,
ParseContext context)
Parses a document stream into a sequence of XHTML SAX events.
|
void |
setEnableAutoSpace(boolean v)
Deprecated.
|
void |
setExtractAnnotationText(boolean v)
Deprecated.
|
void |
setInitializableProblemHandler(InitializableProblemHandler initializableProblemHandler) |
void |
setOcrImageType(java.lang.String imageType) |
void |
setOcrStrategy(java.lang.String ocrStrategyString) |
void |
setPDFParserConfig(PDFParserConfig config) |
void |
setSortByPosition(boolean v)
Deprecated.
|
void |
setSuppressDuplicateOverlappingText(boolean v)
Deprecated.
|
parse
public static final java.lang.String PASSWORD
PasswordProvider
on the ParseContext
insteadpublic java.util.Set<MediaType> getSupportedTypes(ParseContext context)
Parser
getSupportedTypes
in interface Parser
context
- parse contextpublic void parse(java.io.InputStream stream, org.xml.sax.ContentHandler handler, Metadata metadata, ParseContext context) throws java.io.IOException, org.xml.sax.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.
parse
in interface Parser
stream
- the document stream (input)handler
- handler for the XHTML SAX events (output)metadata
- document metadata (input and output)context
- parse contextjava.io.IOException
- if the document stream could not be readorg.xml.sax.SAXException
- if the SAX events could not be processedTikaException
- if the document could not be parsedpublic PDFParserConfig getPDFParserConfig()
public void setPDFParserConfig(PDFParserConfig config)
public boolean getEnableAutoSpace()
getPDFParserConfig()
setEnableAutoSpace(boolean)
public void setEnableAutoSpace(boolean v)
setPDFParserConfig(PDFParserConfig)
public boolean getExtractAnnotationText()
getPDFParserConfig()
public void setExtractAnnotationText(boolean v)
setPDFParserConfig(PDFParserConfig)
public boolean getSuppressDuplicateOverlappingText()
getPDFParserConfig()
public void setSuppressDuplicateOverlappingText(boolean v)
setPDFParserConfig(PDFParserConfig)
public boolean getSortByPosition()
getPDFParserConfig()
setSortByPosition(boolean)
@Field public void setSortByPosition(boolean v)
setPDFParserConfig(PDFParserConfig)
@Field public void setOcrStrategy(java.lang.String ocrStrategyString)
@Field public void setOcrImageType(java.lang.String imageType)
public void setInitializableProblemHandler(InitializableProblemHandler initializableProblemHandler)
public void initialize(java.util.Map<java.lang.String,Param> params) throws TikaConfigException
initialize
in interface Initializable
params
- params to use for initializationTikaConfigException
public void checkInitialization(InitializableProblemHandler handler) throws TikaConfigException
checkInitialization
in interface Initializable
handler
- if there is a problem and no
custom initializableProblemHandler has been configured
via Initializable parameters,
this is called to respond.TikaConfigException
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"