spring-projects / spring-projects/spring-ai
ParagraphPdfDocumentReader unconditionally prints PDF Table of Contents to stdout
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
While testing ParagraphPdfDocumentReader, I noticed that creating the reader prints the entire PDF outline (Table of Contents) to the console.
This happens automatically during reader initialization without any configuration or debug option.
The behavior comes from the ParagraphManager constructor.
At line 67, the constructor calls
it executes every time a ParagraphManager instance is created.
ParagraphPdfDocumentReader always prints the Table of Contents to the console. If you're reading many PDFs, the logs become messy and difficult to follow.
Expected Behavior
When creating a ParagraphPdfDocumentReader, no output should be written to the console during initialization.
If the PDF outline (Table of Contents) is useful for debugging, it should only be shown when debug logging is explicitly enabled.
Current Behavior
Every time a ParagraphPdfDocumentReader is created, the complete PDF outline (Table of Contents) is printed to System.out.
After investigating the source code, I found that this happens in the ParagraphManager constructor (around line 67), where the following line executes unconditionally on every new instance:
printParagraph(this.rootParagraph, System.out);
Why This Matters
Since the output is written directly to System.out, it cannot be controlled through the application's logging configuration.
When processing multiple PDF files, the console becomes filled with the Table of Contents for every document, making logs noisy and difficult to read.
I also noticed that other classes in the same module — PagePdfDocumentReader and ForkPDFLayoutTextStripper — use the project's logging framework instead of writing directly to the console, so this behavior seems inconsistent.
Possible Improvement
Use the existing Commons Logging framework with a debug-level guard, consistent with the pattern already used in sibling classes:
private static final Log logger = LogFactory.getLog(ParagraphManager.class);
if (logger.isDebugEnabled()) {
printParagraph(this.rootParagraph, debugStream);
}
This would make the output opt-in via standard Spring logging configuration instead of always printing to stdout.
Environment
- Spring AI version: 1.0.0
- Java version: 17
- OS: Windows 11
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the ParagraphManager constructor, which ParagraphPdfDocumentReader invokes during initialization, and compare its output handling with PagePdfDocumentReader and ForkPDFLayoutTextStripper. Verify the current unconditional System.out behavior and ensure initialization produces no console output by default, with the outline visible only when debug logging is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100