Skip to content

Commit

Permalink
Allow title, subject, author, and keywords to be unset with an empty …
Browse files Browse the repository at this point in the history
…string argument.
  • Loading branch information
Frederick D. Hansen committed Jun 20, 2023
1 parent dbe6148 commit f31fb5f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ocrmypdf/_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,16 @@ def report_on_metadata(missing):
del meta['dc:title']
missing = set(meta_original.keys()) - set(meta.keys())
report_on_metadata(missing)
# If the user explicitly specified an empty string for any
# of the following, they should be unset.
if options.title == '' and 'dc:title' in meta:
del meta['dc:title']
if options.author == '' and 'dc:creator' in meta:
del meta['dc:creator']
if options.subject == '' and 'dc:description' in meta:
del meta['dc:description']
if options.keywords == '' and 'pdf:Keywords' in meta:
del meta['pdf:Keywords']

optimizing = context.plugin_manager.hook.is_optimization_enabled(
context=context
Expand Down

0 comments on commit f31fb5f

Please sign in to comment.