如何在不使用 pypdf2 删除的情况下使注释静态

How to make annotations static without removing using pypdf2

提问人:Prabhakaran 提问时间:11/6/2023 最后编辑:Prabhakaran 更新时间:11/7/2023 访问量:50

问:

我的 pdf 中有很多注释,它们都是可编辑的,我想将其转换为不可编辑的,我不知道如何使其静态,我使用了下面的代码,但它完全删除了注释。

import PyPDF2

with open('drawing.pdf', 'rb') as pdf_obj:
    pdf = PyPDF2.PdfReader(pdf_obj)
    out = PyPDF2.PdfWriter()
    for page in pdf.pages:
        if page.annotations:
            page.annotations.clear()    # This line is removing the annotations, here I would like to make it static
        out.add_page(page)
with open('output.pdf', 'wb') as f: 
    out.write(f)

我不想使用 pypdftk,因为它依赖于操作系统,而这都是关于表单字段的

更新 1

更准确地说,我试图压扁indirect objects

python pypdf

评论

0赞 Prabhakaran 11/6/2023
@KJ可能是的
0赞 Prabhakaran 11/7/2023
@KJ 但我的情况不是表单字段,它可以是任何图层
0赞 Prabhakaran 11/8/2023
@KJ 谢谢你理解并试图通过木偶师解决这个问题

答: 暂无答案