我正在使用包含超链接占位符的Google幻灯片创建PDF文档。在本地计算机上,我想用本地超链接替换这些占位符。
要做到这一点,我使用的是perl搜索和替换功能:
perl -i~ -0777 -pe 's/\/URI\s*\/URI\s*\(\#Tools_notepad\)/\/Launch\/F(C:\/\/Program Files (x86)\/\/Notepad\+\+\/\/notepad\+\+\.exe)/g' link_problem.pdf
之后,我想使用pdftk剪切页面并获取java NullPointer:
$ pdftk link_problem.pdf cat 1 output link_problem_pdftked.pdf
Error: Unexpected Exception in open_reader()
java.lang.NullPointerException
at 0x0059a84e (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\Throwable.java)
at 0x0059ad42 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\Throwable.java)
at 0x0059adf3 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\Throwable.java)
at 0x005e9bed (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\Exception.java)
at 0x005ba4bd (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\RuntimeException.java)
at 0x005b91ad (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\NullPointerException.java)
at 0x00597242 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\prims.cc)
at 0x004e1e81 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\java_lib.jar)
at 0x004e04c6 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\java_lib.jar)
at 0x004df3e2 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\java_lib.jar)
at 0x004df38a (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\java_lib.jar)
at 0x0041a16a (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\pdftk.cc)
at 0x0041af94 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\pdftk.cc)
at 0x0041d187 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\pdftk.cc)
at 0x00421e89 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\pdftk.cc)
at 0x0042298a (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\pdftk.cc)
at 0x0058ed52 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\crt1.c)
at 0x0058ede4 (C:\Users\ngrebner\Documents\OSOCC-Structure\04 Operations\tmp\crt1.c)
at 0x770c3366 (Unknown Source)
at 0x776a98fe (Unknown Source)
at 0x776a98d1 (Unknown Source)
Error: Failed to open PDF file:
link_problem.pdf
Errors encountered. No output created.
Done. Input errors, so no output created.
使用QPDF我对这个问题有所了解:
$ qpdf --check link_problem.pdf
WARNING: link_problem.pdf: file is damaged
WARNING: link_problem.pdf (file position 112664): xref not found
WARNING: link_problem.pdf: Attempting to reconstruct cross-reference table
operation for Dictionary object attempted on object of wrong type
现在,显然通过使用Perl操作PDF文件,我更改了外部参照引用,而pdftk无法处理。请注意:PDF阅读器现在可以正常使用该文件。
一种解决方案是首先使用pdftk,然后使用perl,但这会导致我的工作流程出现其他问题。
以下是我的最低示例PDF文件的链接:https://drive.google.com/open?id=0BwvpX97bvnDuT1FhTGFxbWlueHc
有没有人知道在使用perl命令后如何拆分文件?