目前,我已将许多 PDF 合并在一起以创建一个 PDF。我添加了元数据信息,其中包括“创建”和“修改”两个字段,但结果这些字段仍然不显示信息。这是我的源代码:
import re
import os
import fitz
from datetime import datetime
def importMetaData(path):
regex = r"^r20ut(\d+)ej(\d+)$"
r_UM = re.compile(regex)
extension = [".pdf"]
now = datetime.now() # current date and time
date_time = now.strftime("%m/%d/%Y %H:%M:%S %p")
print("date and time:",date_time)
Number = ""
for root, dirs, files in os.walk(path):
for file in files:
ext = os.path.splitext(file)[-1].lower()
f_name = os.path.splitext(file)[0]
if ext in extension:
if r_UM.search(f_name) is not None:
if root.endswith("thuan1"):
Number = dictRNumber["code1"]
elif root.endswith("thuan2"):
Number = dictRNumber["code2"]
else:
continue
inforPDF=fitz.open(os.path.join(root, file))
inforPDF.set_metadata({})
inforPDF.set_metadata(
{
"producer": "Microsoft® Word for Office 365",
"author": "Thuan",
"modDate": date_time,
"title": "Data Analysis",
"creationDate": date_time,
"creator": "Microsoft® Word for Office 365",
"subject": Number
})
inforPDF.save(os.path.join(root, f_name+".pdf"))
图片
你能给我一些建议吗?