在未压缩的 pdf 文档中,存在以下不确定格式的“流对象”((0,0) 为左下角),伪正则表达式形式:
(x1 y1 m x2 y2 l [whitespace or blank or newline seperator symbol])* S (BT .* ET)*
在哪里
x1, y1, x2, y2 are coordinates
l probably for "draw line"
m move to, "from to" or "merge"
S is the command for "draw" or the like
BT Begin Text
ET End Text
所有命令后缀。
编辑:
一种可能的 Java 正则表达式是(参考 PDF32000_2008.pdf),在未压缩的 pdf 源中用空格替换换行符后:
((\s+\d+(\.\d+)?){2}(\s+m|\s+l|(\s+\d+(\.\d+)?){2}(\s+re|\s+y|\s+v|(\s+\d+(\.\d+)?){2}\s+c))\s+)+([SsFn]|[fBb](\*)?)
流中还有其他元素,如“W*”或“Q q”,它们似乎在一般情况下调整线条粗细或字体属性。由于我无法找到特定的语言规范,这就是我从实验中推断出来的。
使用此信息和文本标记的坐标(在 ET 和 BT 之间),可以推断表格单元格宽度、表格起始结束位置(用于识别不同表格)。
问题仍然是解压缩任何类型的流。使用 pdftk 我能够解压缩从 openoffice writer 创建的 pdf 文件,但任意 pdf 文件中仍然有神秘符号。
更多信息:
http://www.gnupdf.org/Introduction_to_PDF
http://blog.idrsolutions.com/2011/05/understanding-the-pdf-file-format-%E2%80%93-carriage-returns-spaces-and-other-gaps/
http://blog.idrsolutions.com/2012/03/understanding-the-pdf-file-format-names-locations/
http://blog.idrsolutions.com/2011/05/understanding-the-pdf-file-format-%E2%80%93-pdf-xref-tables-explained/
PDF页面流优化器库?
http://www.gnupdf.org/Stream