public class PDFParser
extends org.apache.tika.parser.AbstractParser
implements org.apache.tika.parser.RenderingParser, org.apache.tika.config.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 org.apache.tika.mime.MediaType |
MEDIA_TYPE |
static String |
PASSWORD
Deprecated.
Supply a
PasswordProvider on the ParseContext instead |
| Constructor and Description |
|---|
PDFParser() |
| Modifier and Type | Method and Description |
|---|---|
void |
checkInitialization(org.apache.tika.config.InitializableProblemHandler handler) |
float |
getAverageCharTolerance() |
float |
getDropThreshold() |
ImageGraphicsEngineFactory |
getImageGraphicsEngineFactory() |
String |
getImageStrategy() |
int |
getMaxIncrementalUpdates() |
long |
getMaxMainMemoryBytes() |
int |
getOcrDPI() |
String |
getOcrImageFormatName() |
float |
getOcrImageQuality() |
String |
getOcrImageType() |
String |
getOcrRenderingStrategy() |
String |
getOcrStrategy() |
String |
getOcrStrategyAuto() |
protected org.apache.pdfbox.pdmodel.PDDocument |
getPDDocument(InputStream inputStream,
String password,
org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting,
org.apache.tika.metadata.Metadata metadata,
org.apache.tika.parser.ParseContext parseContext) |
protected org.apache.pdfbox.pdmodel.PDDocument |
getPDDocument(InputStream stream,
org.apache.tika.io.TikaInputStream tstream,
String password,
org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting,
org.apache.tika.metadata.Metadata metadata,
org.apache.tika.parser.ParseContext context) |
protected org.apache.pdfbox.pdmodel.PDDocument |
getPDDocument(Path path,
String password,
org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting,
org.apache.tika.metadata.Metadata metadata,
org.apache.tika.parser.ParseContext parseContext) |
PDFParserConfig |
getPDFParserConfig() |
org.apache.tika.renderer.Renderer |
getRenderer() |
float |
getSpacingTolerance() |
Set<org.apache.tika.mime.MediaType> |
getSupportedTypes(org.apache.tika.parser.ParseContext context) |
void |
initialize(Map<String,org.apache.tika.config.Param> params)
This is a no-op.
|
boolean |
isAllowExtractionForAccessibility() |
boolean |
isCatchIntermediateExceptions() |
boolean |
isDetectAngles() |
boolean |
isEnableAutoSpace() |
boolean |
isExtractAcroFormContent() |
boolean |
isExtractActions() |
boolean |
isExtractAnnotationText()
Deprecated.
|
boolean |
isExtractBookmarksText() |
boolean |
isExtractFontNames() |
boolean |
isExtractIncrementalUpdateInfo() |
boolean |
isExtractInlineImageMetadataOnly() |
boolean |
isExtractInlineImages() |
boolean |
isExtractMarkedContent() |
boolean |
isExtractUniqueInlineImagesOnly() |
boolean |
isIfXFAExtractOnlyXFA() |
boolean |
isParseIncrementalUpdates() |
boolean |
isSetKCMS() |
boolean |
isSortByPosition()
Deprecated.
|
boolean |
isSuppressDuplicateOverlappingText()
Deprecated.
|
boolean |
isThrowOnEncryptedPayload() |
void |
parse(InputStream stream,
ContentHandler handler,
org.apache.tika.metadata.Metadata metadata,
org.apache.tika.parser.ParseContext context) |
void |
setAllowExtractionForAccessibility(boolean allowExtractionForAccessibility) |
void |
setAverageCharTolerance(float averageCharTolerance) |
void |
setCatchIntermediateExceptions(boolean catchIntermediateExceptions) |
void |
setDetectAngles(boolean detectAngles) |
void |
setDropThreshold(float dropThreshold) |
void |
setEnableAutoSpace(boolean v)
If true (the default), the parser should estimate
where spaces should be inserted between words.
|
void |
setExtractAcroFormContent(boolean extractAcroFormContent) |
void |
setExtractActions(boolean extractActions) |
void |
setExtractAnnotationText(boolean v)
If true (the default), text in annotations will be
extracted.
|
void |
setExtractBookmarksText(boolean extractBookmarksText) |
void |
setExtractFontNames(boolean extractFontNames) |
void |
setExtractIncrementalUpdateInfo(boolean setExtractIncrementalUpdateInfo)
Whether or not to scan a PDF for incremental updates.
|
void |
setExtractInlineImageMetadataOnly(boolean extractInlineImageMetadataOnly) |
void |
setExtractInlineImages(boolean extractInlineImages) |
void |
setExtractMarkedContent(boolean extractMarkedContent) |
void |
setExtractUniqueInlineImagesOnly(boolean extractUniqueInlineImagesOnly) |
void |
setIfXFAExtractOnlyXFA(boolean ifXFAExtractOnlyXFA) |
void |
setImageGraphicsEngineFactory(ImageGraphicsEngineFactory imageGraphicsEngineFactory) |
void |
setImageStrategy(String imageStrategy) |
void |
setMaxIncrementalUpdates(int maxIncrementalUpdates)
Set the maximum number of incremental updates to parse
|
void |
setMaxMainMemoryBytes(long maxMainMemoryBytes) |
void |
setOcrDPI(int dpi) |
void |
setOcrImageFormatName(String formatName) |
void |
setOcrImageQuality(float imageQuality) |
void |
setOcrImageType(String imageType) |
void |
setOcrRenderingStrategy(String ocrRenderingStrategy) |
void |
setOcrStrategy(String ocrStrategyString) |
void |
setOcrStrategyAuto(String ocrStrategyAuto) |
void |
setParseIncrementalUpdates(boolean parseIncrementalUpdates)
If set to true, this will parse incremental updates if they exist
within a PDF.
|
void |
setPDFParserConfig(PDFParserConfig config) |
void |
setRenderer(org.apache.tika.renderer.Renderer renderer) |
void |
setSetKCMS(boolean setKCMS) |
void |
setSortByPosition(boolean v)
If true, sort text tokens by their x/y position
before extracting text.
|
void |
setSpacingTolerance(float spacingTolerance) |
void |
setSuppressDuplicateOverlappingText(boolean v)
If true, the parser should try to remove duplicated
text over the same region.
|
void |
setThrowOnEncryptedPayload(boolean throwOnEncryptedPayload)
If the file is a 'Collection' and contains an embedded file with a
defined 'AssociatedFile' value of 'EncryptedPayload', then throw an
EncryptedDocumentException. |
public static final String PASSWORD
PasswordProvider on the ParseContext insteadpublic static final org.apache.tika.mime.MediaType MEDIA_TYPE
public Set<org.apache.tika.mime.MediaType> getSupportedTypes(org.apache.tika.parser.ParseContext context)
getSupportedTypes in interface org.apache.tika.parser.Parserpublic void parse(InputStream stream, ContentHandler handler, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context) throws IOException, SAXException, org.apache.tika.exception.TikaException
parse in interface org.apache.tika.parser.ParserIOExceptionSAXExceptionorg.apache.tika.exception.TikaExceptionprotected org.apache.pdfbox.pdmodel.PDDocument getPDDocument(InputStream stream, org.apache.tika.io.TikaInputStream tstream, String password, org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext context) throws IOException, org.apache.tika.exception.EncryptedDocumentException
IOExceptionorg.apache.tika.exception.EncryptedDocumentExceptionprotected org.apache.pdfbox.pdmodel.PDDocument getPDDocument(InputStream inputStream, String password, org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.ParseContext parseContext) throws IOException
IOExceptionprotected org.apache.pdfbox.pdmodel.PDDocument getPDDocument(Path path, String password, org.apache.pdfbox.io.MemoryUsageSetting memoryUsageSetting, org.apache.tika.metadata.Metadata metadata, org.apache.tika.parser.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 setOcrStrategy(String ocrStrategyString)
public String getOcrStrategy()
@Field public void setOcrStrategyAuto(String ocrStrategyAuto)
public String getOcrStrategyAuto()
@Field public void setOcrRenderingStrategy(String ocrRenderingStrategy)
public String getOcrRenderingStrategy()
@Field public void setOcrImageType(String imageType)
public String getOcrImageType()
@Field public void setOcrDPI(int dpi)
public int getOcrDPI()
@Field public void setOcrImageQuality(float imageQuality)
public float getOcrImageQuality()
@Field public void setOcrImageFormatName(String formatName)
public String getOcrImageFormatName()
@Field public void setExtractBookmarksText(boolean extractBookmarksText)
public boolean isExtractBookmarksText()
@Field public void setExtractInlineImages(boolean extractInlineImages)
public boolean isExtractInlineImages()
@Field public void setExtractInlineImageMetadataOnly(boolean extractInlineImageMetadataOnly)
public boolean isExtractInlineImageMetadataOnly()
@Field public void setAverageCharTolerance(float averageCharTolerance)
public float getAverageCharTolerance()
@Field public void setSpacingTolerance(float spacingTolerance)
public float getSpacingTolerance()
@Field public void setCatchIntermediateExceptions(boolean catchIntermediateExceptions)
public boolean isCatchIntermediateExceptions()
@Field public void setExtractAcroFormContent(boolean extractAcroFormContent)
public boolean isExtractAcroFormContent()
@Field public void setIfXFAExtractOnlyXFA(boolean ifXFAExtractOnlyXFA)
public boolean isIfXFAExtractOnlyXFA()
@Field public void setAllowExtractionForAccessibility(boolean allowExtractionForAccessibility)
public boolean isAllowExtractionForAccessibility()
@Field public void setExtractUniqueInlineImagesOnly(boolean extractUniqueInlineImagesOnly)
public boolean isExtractUniqueInlineImagesOnly()
@Field public void setExtractActions(boolean extractActions)
public boolean isExtractActions()
@Field public void setExtractFontNames(boolean extractFontNames)
public boolean isExtractFontNames()
@Field public void setSetKCMS(boolean setKCMS)
public boolean isSetKCMS()
@Field public void setDetectAngles(boolean detectAngles)
public boolean isDetectAngles()
@Field public void setExtractMarkedContent(boolean extractMarkedContent)
public boolean isExtractMarkedContent()
@Field public void setDropThreshold(float dropThreshold)
public float getDropThreshold()
@Field public void setMaxMainMemoryBytes(long maxMainMemoryBytes)
@Field public void setExtractIncrementalUpdateInfo(boolean setExtractIncrementalUpdateInfo)
setExtractIncrementalUpdateInfo - public long getMaxMainMemoryBytes()
public boolean isExtractIncrementalUpdateInfo()
@Field public void setParseIncrementalUpdates(boolean parseIncrementalUpdates)
true, this will override
setExtractIncrementalUpdateInfo(boolean).parseIncrementalUpdates - public boolean isParseIncrementalUpdates()
@Field public void setMaxIncrementalUpdates(int maxIncrementalUpdates)
maxIncrementalUpdates - public int getMaxIncrementalUpdates()
@Field public void setThrowOnEncryptedPayload(boolean throwOnEncryptedPayload)
EncryptedDocumentException.
Microsoft IRM v2 wraps the encrypted document inside a container PDF. See TIKA-4082.
The goal of this is to make the user experience the same for traditionally encrypted files and PDFs that are containers for `EncryptedPayload`s.
The default value is false.
throwOnEncryptedPayload - public boolean isThrowOnEncryptedPayload()
public void initialize(Map<String,org.apache.tika.config.Param> params) throws org.apache.tika.exception.TikaConfigException
initialize in interface org.apache.tika.config.Initializableparams - params to use for initializationorg.apache.tika.exception.TikaConfigExceptionpublic void checkInitialization(org.apache.tika.config.InitializableProblemHandler handler)
throws org.apache.tika.exception.TikaConfigException
checkInitialization in interface org.apache.tika.config.Initializableorg.apache.tika.exception.TikaConfigExceptionpublic void setRenderer(org.apache.tika.renderer.Renderer renderer)
setRenderer in interface org.apache.tika.parser.RenderingParserpublic org.apache.tika.renderer.Renderer getRenderer()
@Field public void setImageGraphicsEngineFactory(ImageGraphicsEngineFactory imageGraphicsEngineFactory)
public ImageGraphicsEngineFactory getImageGraphicsEngineFactory()
@Field public void setImageStrategy(String imageStrategy)
public String getImageStrategy()
Copyright © 2007–2024 The Apache Software Foundation. All rights reserved.