当前位置: 首页 > news >正文

解决:PDFBox报的java.io.IOException: Missing root object specification in trailer

文章目录

  • 问题描述
  • 原因分析
  • 解决方案

问题描述

使用pdfbox类库操作pdf文件时,遇到下面的报错信息:
java.io.IOException: Missing root object specification in trailer

PDFBox参考:
https://pdfbox.apache.org/
Apache PDFBox 库是一个开源的用于处理 PDF 文档的 Java 工具。


原因分析

目前看下来有两种原因:

  1. pdf文件格式有损坏,无法读取
  2. 使用的pdfbox版本有相关漏洞

解决方案

针对上面的 原因一,检查pdf文件格式,再操作。

针对上面的 原因二,可以通过升级pdfbox版本来解决

Apache PDFBox 2.0.6 发布了,这个版本是基于 2.0.5 版本的增量式 bug 修复版本,包含了几个修复和小改进,在下面的release notes中就可以看到,修复了该问题:
Apache PDFBox 2.0.6 Release Notes

内容如下:

Sub-task
[PDFBOX-3302] - Explicit support for certification signatures
Bug
[PDFBOX-3313] - Java 9 InaccessibleObjectException
[PDFBOX-3318] - IllegalArgumentException in PDPageTree constructor: root cannot be null
[PDFBOX-3347] - COSName parsing doesn't handle ISO-8859-1 encoded bytes
[PDFBOX-3519] - COSName is not ascii
[PDFBOX-3545] - COSParser.parseXref failing if startXrefOffset over pdf size
[PDFBOX-3687] - PDFBox doesn't respect different setting of /DA at PDAnnotationWidget level to /DA at PDField level
[PDFBOX-3717] - java.io.IOException: Missing root object specification in trailer
[PDFBOX-3723] - FDFField.getValue() doesn't return the values in line with the Javadoc.
[PDFBOX-3724] - Wrong size in rendering of some artifacts
[PDFBOX-3726] - NPE when setting the field value in an AcroForm and the NormalAppearance entry exists but is COSNull
[PDFBOX-3727] - "premature EOF, image will be incomplete"
[PDFBOX-3728] - org.apache.pdfbox.cos.COSDictionary cannot be cast to org.apache.pdfbox.cos.COSStream
[PDFBOX-3731] - IOException: Found Token[kind=NAME, text=bind] but expected ND at offset 91
[PDFBOX-3732] - IllegalArgumentException when refreshing an appearance and no font resources are defined
[PDFBOX-3733] - image added to pdf by tool AddImageToPDF is turn-overed
[PDFBOX-3738] - Signature not visible on Acrobat
[PDFBOX-3739] - ImageWriterIterator.next() and ImageReaderIterator.next() can return null
[PDFBOX-3740] - Standard 14 and Encoding
[PDFBOX-3741] - usage of default colorspace not checked by preflight
[PDFBOX-3742] - Unknown dir object c='>' cInt=62 peek='>' peekInt=62
[PDFBOX-3743] - Running GC between signing and saving document closes stream
[PDFBOX-3745] - Wrong character width
[PDFBOX-3747] - CmapSubtable#getCharCodes provides values in random order
[PDFBOX-3748] - java.lang.UnsupportedOperationException: Kerning table version 0 format 2 not yet supported.
[PDFBOX-3750] - java.util.zip.DataFormatException when parsing a PDF
[PDFBOX-3751] - Flattening a pdf with refreshAppearances set to true causes a NullPointerException
[PDFBOX-3752] - PDVariableText text color changes to be the same as the background color after flattening
[PDFBOX-3753] - setting a RadioButton with export values does not update the appearance
[PDFBOX-3754] - Skip << >> in type1 font parser
[PDFBOX-3755] - ClassCastException in PDColor constructor: org.apache.pdfbox.cos.COSNull cannot be cast to org.apache.pdfbox.cos.COSNumber
[PDFBOX-3757] - TTFSubsetter scrambles PostScript names and unicode codepoints when subset contains diaeresis
[PDFBOX-3761] - Exception in thread "main" java.lang.NullPointerException
[PDFBOX-3769] - Cannot read JBIG2 image when JBIG2-Image-Decoder is in path
[PDFBOX-3775] - Merge documents fails due to IllegalArgumentException
[PDFBOX-3781] - Existing AcroForm default resources is overwritten by signing code
[PDFBOX-3783] - java.io.IOException: Expected root dictionary, but got this: COSNull{}
[PDFBOX-3784] - Inline image incorrectly parsed
[PDFBOX-3788] - java.lang.RuntimeException: java.io.IOException: Catalog cannot be found
[PDFBOX-3789] - Some text missing in rendering
[PDFBOX-3791] - Long rendering time
[PDFBOX-3837] - PDFBox does not maintain the font appearence of a field if it appears severraly in a PDF Form
Improvement
[PDFBOX-2684] - Javadoc for COSBase.setNeedToBeUpdate
[PDFBOX-3614] - Directly use the BouncyCastleProvider rather than installing it
[PDFBOX-3716] - Read images from byte array
[PDFBOX-3722] - make font cache error message less scary
[PDFBOX-3730] - Encapsulate outputStream into BufferedOutputStream in PDDocument.save()
[PDFBOX-3763] - Optimize SampledImageReader.getStencilImage()
[PDFBOX-3768] - Optimize SampledImageReader.from1Bit()
[PDFBOX-3770] - provide set of page indexes that have page label ranges
[PDFBOX-3772] - Add COSBoolean(false) as option in PDDocumentCatalog's getOpenAction
[PDFBOX-3779] - Add dpi and border parameter to PrintPDF command line utility
http://www.lryc.cn/news/6945.html

相关文章:

  • MAC OSX安装Python环境 + Visual Studio Code
  • 音乐 APP 用户争夺战,火山引擎 VeDI 助力用户体验升级!
  • CAP和BASE理论
  • 基于商品理解的成交能力和成交满意度优化在Lazada的实践
  • idea推送镜像到desktop报错:Cannot run program “docker-credential-desktop“ 系统找不到指定的文件。
  • hive开窗函数
  • 安全多方计算系列笔记1——前世今生
  • 16- 梯度提升分类树GBDT (梯度下降优化) (算法)
  • SpringCloud+Nacos+Gateway
  • 高通开发系列 - linux kernel内核升级msm-3.18升至msm-4.9(2)
  • Spring依赖注入与反转控制到底是个啥?
  • Linux Shell脚本讲解
  • Linux:用户空间非法指针coredump简析
  • 带你玩转Jetson之Deepstream简明教程(四)DeepstreamApp如何使用以及用于工程验证。
  • 快速搭建个人在线书库,随时随地畅享阅读!
  • 电子纸墨水屏的现实应用场景
  • 常量const、引用、指针的大杂烩
  • 宝塔搭建实战php开源likeadmin通用管理移动端uniapp源码(四)
  • Hive的分区表与分桶表内部表外部表
  • 和数集团打造《神念无界:源起山海》,诠释链游领域创新与责任
  • 小白入门模拟IC设计,如何快速学习?
  • 51单片机——中断系统之外部中断实验,小白讲解,相互学习
  • 如何设计一个秒杀系统
  • 厄瓜多尔公司注册方案
  • 安全渗透环境准备(工具下载)
  • 118.(leaflet篇)leaflet空间判断-点与geojson面图层的空间关系(turf实现)
  • 目标检测与目标跟踪算法技术汇总
  • Linux 系统启动过程
  • 【每日一题Day118】LC1124表现良好的最长时间段 | 前缀和+单调栈/哈希表
  • vue使用nprogress(进度条)