Class PdfDocumentReaderConfig.Builder

java.lang.Object
org.springframework.ai.reader.pdf.config.PdfDocumentReaderConfig.Builder
Enclosing class:
PdfDocumentReaderConfig

public static final class PdfDocumentReaderConfig.Builder extends Object
  • Method Details

    • withPageExtractedTextFormatter

      public PdfDocumentReaderConfig.Builder withPageExtractedTextFormatter(ExtractedTextFormatter pageExtractedTextFormatter)
      Formatter of the extracted text.
      Parameters:
      pageExtractedTextFormatter - Instance of the PageExtractedTextFormatter.
      Returns:
      this builder
    • withPagesPerDocument

      public PdfDocumentReaderConfig.Builder withPagesPerDocument(int pagesPerDocument)
      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

      public PdfDocumentReaderConfig.Builder withPageTopMargin(int topMargin)
      Configures the Pdf reader page top margin. Defaults to 0.
      Parameters:
      topMargin - page top margin to use
      Returns:
      this builder
    • withPageBottomMargin

      public PdfDocumentReaderConfig.Builder withPageBottomMargin(int bottomMargin)
      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

      public PdfDocumentReaderConfig.Builder addPageRange(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. May be called multiple times to read multiple, possibly disjoint, ranges; their union is read. A range whose endPage exceeds 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 read
      endPage - the inclusive, one-based last page to read
      Returns:
      this builder
    • build

      public PdfDocumentReaderConfig build()
      Returns the immutable configuration.
      Returns:
      the immutable configuration