altair: chart.save does not support pdf as shown in docs

The docs for saving charts show chart.save('chart.pdf') as one of the options, but running that results in ValueError: unrecognized format: 'pdf', even though altair_saver is installed and from altair_saver import save; save(chart, "chart.pdf") works.

By contrast, chart.save("chart.svg") works fine.

Looking at the docstring of Chart.save, it looks like pdf isn’t even supposed to work: “Supported formats are json, html, png, svg”. But maybe it’s just a matter of wiring it up?

If the issue is more complicated than that (maybe because Chart.save is currently hardwired to use the Selenium backend, which doesn’t offer pdf export?), then I would suggest just removing chart.save('chart.pdf') from the code example and refer users who are interested in pdf export functionality to altair_saver’s docs 😃

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Thanks a lot 😃 It is working now.

What error do you get when trying to save a png? I’m surprised that doesn’t work, because (unlike PDF) it’s covered in the test suite in several places.

Ah, yeah, you’re right. the mimebundle code has been updated, but we neglected to thread through the save method for pdf. This is a bug.