public class PDFParser extends AbstractParser implements RenderingParser, 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 many pdfs do not store table structures.
 So you should not expect table markup for what looks like a table. 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.
 If your PDFs contain marked content or tags, consider
 PDFParserConfig.setExtractMarkedContent(boolean)| Modifier and Type | Field and Description | 
|---|---|
| static MediaType | MEDIA_TYPE | 
| static String | PASSWORDDeprecated. 
 Supply a  PasswordProvideron theParseContextinstead | 
| Constructor and Description | 
|---|
| PDFParser() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | checkInitialization(InitializableProblemHandler handler) | 
| protected org.apache.pdfbox.pdmodel.PDDocument | getPDDocument(InputStream inputStream,
             String password,
             org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting,
             Metadata metadata,
             ParseContext parseContext) | 
| protected org.apache.pdfbox.pdmodel.PDDocument | getPDDocument(Path path,
             String password,
             org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting,
             Metadata metadata,
             ParseContext parseContext) | 
| PDFParserConfig | getPDFParserConfig() | 
| Set<MediaType> | getSupportedTypes(ParseContext context)Returns the set of media types supported by this parser when used
 with the given parse context. | 
| void | initialize(Map<String,Param> params)This is a no-op. | 
| boolean | isEnableAutoSpace() | 
| boolean | isExtractAnnotationText()Deprecated. 
 | 
| boolean | isSortByPosition()Deprecated. 
 | 
| boolean | isSuppressDuplicateOverlappingText()Deprecated. 
 | 
| void | parse(InputStream stream,
     ContentHandler handler,
     Metadata metadata,
     ParseContext context)Parses a document stream into a sequence of XHTML SAX events. | 
| void | setDropThreshold(float dropThreshold) | 
| 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 | setImageGraphicsEngineFactory(ImageGraphicsEngineFactory imageGraphicsEngineFactory) | 
| void | setImageStrategy(String imageStrategy) | 
| void | setMaxMainMemoryBytes(long maxMainMemoryBytes) | 
| void | setOcrImageType(String imageType) | 
| void | setOcrRenderingStrategy(String ocrRenderingStrategy) | 
| void | setOcrStrategy(String ocrStrategyString) | 
| void | setOcrStrategyAuto(String ocrStrategyAuto) | 
| void | setPDFParserConfig(PDFParserConfig config) | 
| void | setRenderer(Renderer renderer) | 
| 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. | 
parsepublic static final String PASSWORD
PasswordProvider on the ParseContext insteadpublic static final MediaType MEDIA_TYPE
public Set<MediaType> getSupportedTypes(ParseContext context)
ParsergetSupportedTypes in interface Parsercontext - parse contextpublic void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException
ParserThe 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 Parserstream - 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 parsedprotected org.apache.pdfbox.pdmodel.PDDocument getPDDocument(InputStream inputStream, String password, org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting, Metadata metadata, ParseContext parseContext) throws IOException
IOExceptionprotected org.apache.pdfbox.pdmodel.PDDocument getPDDocument(Path path, String password, org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting, Metadata metadata, ParseContext parseContext) throws IOException
IOExceptionpublic PDFParserConfig getPDFParserConfig()
public void setPDFParserConfig(PDFParserConfig config)
public boolean isEnableAutoSpace()
setEnableAutoSpace(boolean)@Field public void setEnableAutoSpace(boolean v)
public boolean isExtractAnnotationText()
getPDFParserConfig()@Field public void setExtractAnnotationText(boolean v)
public boolean isSuppressDuplicateOverlappingText()
getPDFParserConfig()@Field public void setSuppressDuplicateOverlappingText(boolean v)
public boolean isSortByPosition()
getPDFParserConfig()setSortByPosition(boolean)@Field public void setSortByPosition(boolean v)
@Field public void setDropThreshold(float dropThreshold)
@Field public void setMaxMainMemoryBytes(long maxMainMemoryBytes)
public void initialize(Map<String,Param> params) throws TikaConfigException
initialize in interface Initializableparams - params to use for initializationTikaConfigExceptionpublic void checkInitialization(InitializableProblemHandler handler) throws TikaConfigException
checkInitialization in interface Initializablehandler - if there is a problem and no
                       custom initializableProblemHandler has been configured
                       via Initializable parameters,
                       this is called to respond.TikaConfigExceptionpublic void setRenderer(Renderer renderer)
setRenderer in interface RenderingParser@Field public void setImageGraphicsEngineFactory(ImageGraphicsEngineFactory imageGraphicsEngineFactory)
Copyright © 2007–2022 The Apache Software Foundation. All rights reserved.