Skip to content
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

Add title parameter to specify titles for SVGs and PDFs #15

Closed
flying-sheep opened this issue Dec 4, 2015 · 6 comments
Closed

Add title parameter to specify titles for SVGs and PDFs #15

flying-sheep opened this issue Dec 4, 2015 · 6 comments
Assignees

Comments

@flying-sheep
Copy link

Both PDFs (through metadata) and SVGs (through title) have the capability for titles.

instead of ignoring the title parameter, it should work for all output types that have the necessary capabilities.

@flying-sheep flying-sheep changed the title Add title parameter to specify titles for PNGs and PDFs Add title parameter to specify titles for SVGs and PDFs Dec 4, 2015
@s-u
Copy link
Owner

s-u commented Dec 4, 2015

AFAIK cairographics still doesn't support metadata so there is no way for Cairo to do that until that feature is added upstream. At least support for PDF metadata has been discussed on the cairographics lists some 7 years ago, but given that it's still not there I would not hold my breath.

@s-u
Copy link
Owner

s-u commented Sep 15, 2022

Since cairographics version 1.16 there is now cairo_pdf_surface_set_metadata(surface, CAIRO_PDF_METADATA_TITLE, ...) so we could implement it now ...

@flying-sheep
Copy link
Author

Neat!

@s-u
Copy link
Owner

s-u commented Sep 15, 2022

After such an encouragement ;) this is now implemented for the PDF back-end. I have also added other metadata entries supported by cairo. Note that this requires cairo library version 1.16, the extra arguments will be silently ignored when used with older versions.

Unfortunately, the SVG back-end in cairo has not added this option. I will close this issue for now. If someone is interested in SVG, they may need to file it upstream and it would be then easy to add it here since we have the precedent of handling this for PDF.

@s-u s-u closed this as completed Sep 15, 2022
@flying-sheep
Copy link
Author

It’s the little things! Having a their PDF viewer show something meaningful in its window title could just make the difference between some overworked PhD student rediscovering what that specific plot meant and how it fits into the whole.

Thank you for doing it, I think I couldn’t have quickly figured out how to do the necessary incantations in pdf-backend.c

@flying-sheep
Copy link
Author

And it works! With IRkernel/repr#156:

> install.packages("Cairo", repo="https://rforge.net/")
> library(repr)
> plot(sqrt(1:10))
> title('roots')
> recordPlot() |> repr_pdf() |> writeBin('test.pdf')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants