Class ApachePdfBoxDocumentParser.Builder
java.lang.Object
dev.langchain4j.data.document.parser.apache.pdfbox.ApachePdfBoxDocumentParser.Builder
- Enclosing class:
ApachePdfBoxDocumentParser
Builder for
ApachePdfBoxDocumentParser.
Options that are not set (or set to null) use their default values.- Since:
- 1.25.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates the parser.includeMetadata(@Nullable Boolean includeMetadata) Sets whether the metadata of the PDF file (for example its author or creation date) is added to the parsedDocument.maxCharacters(@Nullable Integer maxCharacters) Sets the maximum number of characters of text that the parser extracts from the whole document.maxCharactersPerPage(@Nullable Integer maxCharactersPerPage) Sets the maximum number of characters that the parser reads from a single page.
-
Method Details
-
includeMetadata
Sets whether the metadata of the PDF file (for example its author or creation date) is added to the parsedDocument.- Parameters:
includeMetadata- whether to include the metadata;nullmeans the default,false- Returns:
- this builder
- Since:
- 1.25.0
-
maxCharacters
Sets the maximum number of characters of text that the parser extracts from the whole document. The count includes the spaces and line breaks that PDFBox adds between words, lines and pages. If the text of a document has more characters, or if PDFBox reads more characters from a single page (counted as formaxCharactersPerPage(Integer)),ApachePdfBoxDocumentParser.parse(InputStream)throws aRuntimeException. So this limit also bounds the memory needed for one page when the limit per page is turned off.- Parameters:
maxCharacters- the maximum number of characters, a positive number, or-1for no limit;nullmeans the default, 10,000,000- Returns:
- this builder
- Since:
- 1.25.0
-
maxCharactersPerPage
public ApachePdfBoxDocumentParser.Builder maxCharactersPerPage(@Nullable Integer maxCharactersPerPage) Sets the maximum number of characters that the parser reads from a single page. The count is the number of characters of the page's text as PDFBox reads it, before it adds spaces and line breaks. Every character drawn on the page counts, also when it is drawn more than once at the same position. If a page contains more characters,ApachePdfBoxDocumentParser.parse(InputStream)throws aRuntimeException.PDFBox keeps every character of a page in memory until the whole page is processed, so this limit bounds the memory needed for one page. A page of dense text usually contains a few thousand characters.
- Parameters:
maxCharactersPerPage- the maximum number of characters per page, a positive number, or-1for no limit;nullmeans the default, 100,000- Returns:
- this builder
- Since:
- 1.25.0
-
build
Creates the parser.- Returns:
- a new
ApachePdfBoxDocumentParser - Throws:
IllegalArgumentException- ifmaxCharacters(Integer)ormaxCharactersPerPage(Integer)is not a positive number or-1- Since:
- 1.25.0
-