Class PdfDocumentReaderConfig.Builder
java.lang.Object
org.springframework.ai.reader.pdf.config.PdfDocumentReaderConfig.Builder
- Enclosing class:
- PdfDocumentReaderConfig
-
Method Summary
Modifier and TypeMethodDescriptionaddPageRange(int startPage, int endPage) Restricts reading to only the given inclusive, one-based page range, allowing callers to skip pages such as covers, tables of contents or appendices.build()Returns the immutable configuration.withPageBottomMargin(int bottomMargin) Configures the Pdf reader page bottom margin.withPageExtractedTextFormatter(ExtractedTextFormatter pageExtractedTextFormatter) Formatter of the extracted text.withPagesPerDocument(int pagesPerDocument) How many pages to put in a single Document instance. 0 stands for all pages.withPageTopMargin(int topMargin) Configures the Pdf reader page top margin.withReversedParagraphPosition(boolean reversedParagraphPosition) Configures the Pdf reader reverse paragraph position.
-
Method Details
-
withPageExtractedTextFormatter
public PdfDocumentReaderConfig.Builder withPageExtractedTextFormatter(ExtractedTextFormatter pageExtractedTextFormatter) Formatter of the extracted text.- Parameters:
pageExtractedTextFormatter- Instance of the PageExtractedTextFormatter.- Returns:
- this builder
-
withPagesPerDocument
How many pages to put in a single Document instance. 0 stands for all pages. Defaults to 1.- Parameters:
pagesPerDocument- Number of page's content to group in single Document.- Returns:
- this builder
-
withPageTopMargin
Configures the Pdf reader page top margin. Defaults to 0.- Parameters:
topMargin- page top margin to use- Returns:
- this builder
-
withPageBottomMargin
Configures the Pdf reader page bottom margin. Defaults to 0.- Parameters:
bottomMargin- page top margin to use- Returns:
- this builder
-
withReversedParagraphPosition
public PdfDocumentReaderConfig.Builder withReversedParagraphPosition(boolean reversedParagraphPosition) Configures the Pdf reader reverse paragraph position. Defaults to false.- Parameters:
reversedParagraphPosition- to reverse or not the paragraph position withing a page.- Returns:
- this builder
-
addPageRange
Restricts reading to only the given inclusive, one-based page range, allowing callers to skip pages such as covers, tables of contents or appendices. May be called multiple times to read multiple, possibly disjoint, ranges; their union is read. A range whoseendPageexceeds the document length is clamped to the last page. When no range is added (the default), the whole document is read.Note: page ranges are a coarse, manual filter based on physical page numbers and are intended for cases where the caller already knows which pages to include. They are currently honored only by
PagePdfDocumentReader; readers that do not support page ranges reject a configuration that sets them.- Parameters:
startPage- the inclusive, one-based first page to readendPage- the inclusive, one-based last page to read- Returns:
- this builder
-
build
Returns the immutable configuration.- Returns:
- the immutable configuration
-