Change metadata of pdf file with pypdf2

前端 未结 4 1157
时光说笑
时光说笑 2020-12-14 05:06

I want to add a metadata key-value pair to the metadata of a pdf file.

I found a several years old answer, but I think this is way to complicated. I guess there is a

4条回答
  •  无人及你
    2020-12-14 05:48

    You can do that using pdfrw

    pip install pdfrw
    

    Then run

    from pdfrw import PdfReader, PdfWriter   
    trailer = PdfReader("myfile.pdf")    
    trailer.Info.WhoAmI = "Tarun Lalwani"    
    PdfWriter("edited.pdf", trailer=trailer).write()
    

    And then check the PDF Custom Properties

提交回复
热议问题