Skip to content

Commit ea09d95

Browse files
committed
TST: Ignore Producer key mismatches in PGF metadata.
Some LaTeX engines ignore the setting of this key in hyperref, but otherwise obey the request metadata. This is likely still okay, but leave a note in the docs as well.
1 parent 87a9b4f commit ea09d95

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/matplotlib/backends/backend_pgf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,9 @@ def __init__(self, filename, *, keep_empty=True, metadata=None):
948948
'Creator', 'Producer', 'CreationDate', 'ModDate', and
949949
'Trapped'. Values have been predefined for 'Creator', 'Producer'
950950
and 'CreationDate'. They can be removed by setting them to `None`.
951+
952+
Note that some versions of LaTeX engines may ignore the 'Producer'
953+
key and set it to themselves.
951954
"""
952955
self._output_name = filename
953956
self._n_figures = 0

lib/matplotlib/tests/test_backend_pgf.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,17 @@ def test_pdf_pages_metadata_check(monkeypatch, system):
257257
if '/PTEX.Fullbanner' in info:
258258
del info['/PTEX.Fullbanner']
259259

260+
# Some LaTeX engines ignore this setting, and state themselves as producer.
261+
producer = info.pop('/Producer')
262+
assert producer == f'Matplotlib pgf backend v{mpl.__version__}' or (
263+
system == 'lualatex' and 'LuaTeX' in producer)
264+
260265
assert info == {
261266
'/Author': 'me',
262267
'/CreationDate': 'D:19700101000000Z',
263268
'/Creator': f'Matplotlib v{mpl.__version__}, https://matplotlib.org',
264269
'/Keywords': 'test,pdf,multipage',
265270
'/ModDate': 'D:19680801000000Z',
266-
'/Producer': f'Matplotlib pgf backend v{mpl.__version__}',
267271
'/Subject': 'Test page',
268272
'/Title': 'Multipage PDF with pgf',
269273
'/Trapped': '/True',

0 commit comments

Comments
 (0)