| 177 | |
| 178 | |
| 179 | def test_multipage_metadata(monkeypatch): |
| 180 | pikepdf = pytest.importorskip('pikepdf') |
| 181 | monkeypatch.setenv('SOURCE_DATE_EPOCH', '0') |
| 182 | |
| 183 | fig, ax = plt.subplots() |
| 184 | ax.plot(range(5)) |
| 185 | |
| 186 | md = { |
| 187 | 'Author': 'me', |
| 188 | 'Title': 'Multipage PDF', |
| 189 | 'Subject': 'Test page', |
| 190 | 'Keywords': 'test,pdf,multipage', |
| 191 | 'ModDate': datetime.datetime( |
| 192 | 1968, 8, 1, tzinfo=datetime.timezone(datetime.timedelta(0))), |
| 193 | 'Trapped': 'True' |
| 194 | } |
| 195 | buf = io.BytesIO() |
| 196 | with PdfPages(buf, metadata=md) as pdf: |
| 197 | pdf.savefig(fig) |
| 198 | pdf.savefig(fig) |
| 199 | |
| 200 | with pikepdf.Pdf.open(buf) as pdf: |
| 201 | info = {k: str(v) for k, v in pdf.docinfo.items()} |
| 202 | |
| 203 | assert info == { |
| 204 | '/Author': 'me', |
| 205 | '/CreationDate': 'D:19700101000000Z', |
| 206 | '/Creator': f'Matplotlib v{mpl.__version__}, https://matplotlib.org', |
| 207 | '/Keywords': 'test,pdf,multipage', |
| 208 | '/ModDate': 'D:19680801000000Z', |
| 209 | '/Producer': f'Matplotlib pdf backend v{mpl.__version__}', |
| 210 | '/Subject': 'Test page', |
| 211 | '/Title': 'Multipage PDF', |
| 212 | '/Trapped': '/True', |
| 213 | } |
| 214 | |
| 215 | |
| 216 | def test_text_urls(): |