exiftool
特定のPDF内のメタデータを更新するために使用するpythonスクリプトがあります。のドキュメントとダウンロードは、次の場所exiftool
にあります: PyExifTool
以下は私の現在のコードです:
if __name__ == '__main__':
from exif_tool import ExifTool, fsencode
source_file = 'D:\\my_file.pdf'
author = 'some author'
keywords = 'some keywords'
subject = 'some subject'
title = 'some title'
with ExifTool('exiftool.exe') as et:
params = map(fsencode, ['-Title=%s' % title,
'-Author=%s' % author,
'-Creator=%s' % author,
'-Subject=%s' % subject,
'-Keywords=%s' % keywords,
'%s' % source_file])
et.execute(*params)
os.remove('%s_original' % source_file)
for key, value in dict(et.get_metadata(source_file)).items():
if key.startswith('PDF:') and ('Author' in key or 'Keywords' in key or 'Title' in key or 'Subject' in key):
print key, value
>>> PDF:Keywords [u'some', u'keywords']
>>> PDF:Title some title
>>> PDF:Subject some subject
>>> PDF:Author some author
上記のコードは機能し、それに応じて PDF メタデータを更新します。しかし、Adobe Acrobat または Adobe Reader で PDF メタを表示すると、件名とキーワードの両方の値がキーワード フィールドに表示されます。
全体として、これはほとんどの場合重大な問題ではありませんが、これに関して多くの苦情が寄せられると予想できます。
小さな構成や設定が欠けているだけかもしれませんが、ドキュメントを読みましたが、これを回避する方法は見つかりませんでした。
誰か考えやアイデアはありますか?