Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Allow deleting pdf metadata keys
And document the standard keys in PdfPages. Also insert the
matplotlib version in the default value of Producer as well
as Creator, to retain a debugging clue in case the user overrides
one of them.
  • Loading branch information
jkseppan committed Jan 5, 2017
commit 529afdc7a2d018f01f8f9fc21129ff57a292b8d5
12 changes: 10 additions & 2 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ def __init__(self, filename, metadata=None):
'Pages': self.pagesObject}
self.writeObject(self.rootObject, root)

revision = ''
# get source date from SOURCE_DATE_EPOCH, if set
# See https://reproducible-builds.org/specs/source-date-epoch/
source_date_epoch = os.getenv("SOURCE_DATE_EPOCH")
Expand All @@ -484,11 +483,13 @@ def __init__(self, filename, metadata=None):

self.infoDict = {
'Creator': 'matplotlib %s, http://matplotlib.org' % __version__,
'Producer': 'matplotlib pdf backend%s' % revision,
'Producer': 'matplotlib pdf backend %s' % __version__,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need the version here? It's in the Creator tag.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought including the version in both would help with debugging when the user has overridden just one of these. If you use Matplotlib as a component of some larger application, you might want to override Creator and leave Producer pointing to the PDF backend.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

'CreationDate': source_date
}
if metadata is not None:
self.infoDict.update(metadata)
self.infoDict = {k: v for (k, v) in self.infoDict.items()
if v is not None}

self.fontNames = {} # maps filenames to internal font names
self.nextFont = 1 # next free internal font name
Expand Down Expand Up @@ -2459,6 +2460,13 @@ def __init__(self, filename, keep_empty=True, metadata=None):
'Document Information Dictionary'), e.g.:
`{'Creator': 'My software', 'Author': 'Me',
'Title': 'Awesome fig'}`

The standard keys are `'Title'`, `'Author'`, `'Subject'`,
`'Keywords'`, `'Creator'`, `'Producer'`, `'CreationDate'`,
`'ModDate'`, and `'Trapped'`. Values have been predefined
for `'Creator'`, `'Producer'` and `'CreationDate'`. They
can be removed by setting them to `None`.

"""
self._file = PdfFile(filename, metadata=metadata)
self.keep_empty = keep_empty
Expand Down