使用pdfbox加载pdf提示推回缓冲区已满

发布时间 2024-01-09 17:01:38作者: 逝年的我们

Caused by: java.io.IOException: Push back buffer is full

[WARN][2024-01-09 16:43:32,892][org.apache.pdfbox.pdfparser.BaseParser]Specified stream length 41367 is wrong. Fall back to reading stream until 'endstream'.
[WARN][2024-01-09 16:43:41,364][org.apache.pdfbox.pdfparser.BaseParser]Specified stream length 79043 is wrong. Fall back to reading stream until 'endstream'.
org.apache.pdfbox.exceptions.WrappedIOException: Could not push back 79043 bytes in order to reparse stream. Try increasing push back buffer using system property org.apache.pdfbox.baseParser.pushBackSize
    at org.apache.pdfbox.pdfparser.BaseParser.parseCOSStream(BaseParser.java:558)

BaseParser可以看到默认的大小是65536,可以根据自己的需求增加系统属性org.apache.pdfbox.baseParser.pushBackSize增加推回缓冲区