python - 通过 PyPDF2 合并两个 PDF,但出现错误 Unexpected destination '/__WKANCHOR_2'

标签 python odoo odoo-9

from PyPDF2 import PdfFileMerger, PdfFileReader
filepath_list = ['/tmp/abc.pdf','/tmp/xyz.pdf']
merger = PdfFileMerger()
for file_name in filepath_list:
 with open(file_name, 'rb') as f:
    merger.append(f)

merger.write("result.pdf")

在通过 python 代码合并 2 pdf 时,我收到了错误意外目的地 '/__WKANCHOR_2' 并且我使用以下代码,请提供解决方案

最佳答案

这是一个临时修复,当您在 append 方法中传入文件时,传入 import_bookmarks=False 。这对我有用

from PyPDF2 import PdfFileMerger, PdfFileReader
filepath_list = ['/tmp/abc.pdf', '/tmp/xyz.pdf']
merger = PdfFileMerger()
for file_name in filepath_list:
 with open(file_name, 'rb') as f:
    merger.append(f, import_bookmarks=False )

merger.write("result.pdf")

关于python - 通过 PyPDF2 合并两个 PDF,但出现错误 Unexpected destination '/__WKANCHOR_2',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50189434/

相关文章:

python - 在 python 中解析 pcap 文件

python - 如何在odoo 8中打印组的外部ID?

javascript - Odoo 网络客户端。无法使用 jquery 选择器选择 html 元素

attributes - 如何在 Odoo 9 的 attrs 中使用名称字段而不是 id?

python - Odoo Onchange 方法不适用于 Many2one 字段

odoo - 在 onchange 中将 one2many 填充到 one2many 中

python - 谁能帮我用 python 读取不断更新的视频文件?

python - DataFrame 计算平均购买价格

python - 属性错误: 'NoneType' object has no attribute 'id' - Odoo v8

python - 带有查询字符串和变量的 Scrapy