FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve PDF metadata support in PGF by QuLogic · Pull Request #17233 · matplotlib/matplotlib · GitHub

Repository navigation

Improve PDF metadata support in PGF - #17233

Merged
tacaswell merged 7 commits into
matplotlib:masterfrom
QuLogic:pgf-pdf-metadata
Jun 8, 2020
Merged

tacaswell merged 7 commits into
matplotlib:masterfrom
QuLogic:pgf-pdf-metadata

Conversation

QuLogic commented Apr 24, 2020

Copy link
Copy Markdown
Member

PR Summary

The PGF backend only supported PDF metadata using the multi-page PdfPages class; this adds support for adding metadata to single-figure saving directly via savefig.

Additionally, refactor the metadata support from the PDF side into a common function to setup and verify metadata that can be used in the PGF side as well. This ensures that the same set of keys is allowed, which weren't before.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Copy Markdown
Member

👍 In principle, but I think that this should get some through tests while we are thinking about it.

Do we want to push this to 3.4 or try to squeeze it in for 3.3?

anntzer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

looks reasonable.

QuLogic commented May 27, 2020

Copy link
Copy Markdown
Member Author

This is difficult to test, because unlike the builtin PDF export, the PGF backend uses latex, which has no pdf.compression setting, and all the metadata is compressed. You can check in evince that the metadata is set from the test though.

anntzer commented Jun 1, 2020

Copy link
Copy Markdown
Contributor

I guess you could possibly use pdfinfo (from poppler) or mutool (from mupdf) as optional test dependency to extract the metadata?

QuLogic commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

It doesn't print Trapped, but it looks like pdfinfo would work for the others. There might be a bug in one or the other, because the printed date is wrong...

QuLogic commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

Also, another possibility is pikepdf, which we could use from Python.

QuLogic added 7 commits June 2, 2020 01:23
This takes keys that match the PDF specification instead of lower-case,
'pdf'-prefixed keys, so is a bit simpler. Also, deprecate ability to
accept key case-insensitively, as that is not done in the PDF backend.
This ensures that the same default values are produced, and more
importantly ensures that the same keys are accepted. Previously, PGF
only allowed a subset of keys.
It's something internal to the PDF backend, and there's no need to
require the metadata to use that type instead of a plain string.
This is supported through the multipage PdfPages, but not direct output
of a single figure via PGF.
They're basically the same, but with different `pgf.texsystem` settings.
QuLogic force-pushed the pgf-pdf-metadata branch from 911e54d to cf4a117 Compare June 2, 2020 22:39

QuLogic commented Jun 2, 2020

Copy link
Copy Markdown
Member Author

That was a good idea, because I found a few bugs in the PGF side, as hyperref seems to have some differing requirements on the format for things.

tacaswell merged commit ecdfa65 into matplotlib:master Jun 8, 2020
QuLogic deleted the pgf-pdf-metadata branch June 8, 2020 20:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL