Download plot as pdf

Hi, I’m want to download my plots (plotly.graph_objs.Figure) as .pdf. How can I do it? Maybe create something like Html.A download button? But how? Thanks.

Upd.
I think, my question comes down to this question: how can I decode dict (which contain ‘data’ and ‘layout’) for creating href and taking it as a callback?