安装库
pip310 install --trusted-host mirrors.aliyun.com pdfrw -i http://mirrors.aliyun.com/pypi/simple/
pdfrw库地址:https://github.com/pmaupin/pdfrw
from pdfrw import PdfReader,PdfWriter
import os
new_title = "www.herokay.cn"
files = os.listdir('./')
for file_path in files:
if os.path.splitext(file_path)[-1]==".pdf":
trailer = PdfReader(file_path)
print(trailer.Info.Title,"\t=>\t",new_title,)
trailer.Info.Title = new_title
PdfWriter(file_path, trailer=trailer).write()
print("finish")