8000 Improve PDF metadata support in PGF by QuLogic · Pull Request #17233 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Improve PDF metadata support in PGF #17233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 8, 2020

Conversation

QuLogic
Copy link
Member
@QuLogic QuLogic commented Apr 24, 2020

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

@tacaswell
Copy link
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?

Copy link
Contributor
@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

looks reasonable.

@QuLogic
Copy link
Member Author
QuLogic commented May 27, 2020

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
Copy link
Contributor
anntzer commented Jun 1, 2020

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

@QuLogic
Copy link
Member Author
QuLogic commented Jun 2, 2020

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
Copy link
Member Author
QuLogic commented Jun 2, 2020

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 QuLogic force-pushed the pgf-pdf-metadata branch from 911e54d to cf4a117 Compare June 2, 2020 22:39
@QuLogic
Copy link
Member Author
QuLogic commented Jun 2, 2020

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 tacaswell merged commit ecdfa65 into matplotlib:master Jun 8, 2020
@QuLogic QuLogic deleted the pgf-pdf-metadata branch June 8, 2020 20:19
Sign up for free to join this conversation o 6478 n GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0