使用pypdf2更改pdf文件的元数据 [英] Change metadata of pdf file with pypdf2

查看:518
本文介绍了使用pypdf2更改pdf文件的元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将元数据键值对添加到pdf文件的元数据中.

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

我找到了几年的答案,但是我认为这很复杂.我想今天有一种更简单的方法: https://stackoverflow.com/a/3257340/633961

I found a several years old answer, but I think this is way to complicated. I guess there is an easier way today: https://stackoverflow.com/a/3257340/633961

我还没有嫁给pypdf2,如果有更简单的方法,那我就这样吗?

I am not married with pypdf2, if there is an easier way, then I go this way?

推荐答案

您可以使用 pdfrw

pip install pdfrw

然后运行

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

然后检查PDF自定义属性

And then check the PDF Custom Properties

这篇关于使用pypdf2更改pdf文件的元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆