# Convert plotly chart to pdf

**URL:** <https://community.plotly.com/t/convert-plotly-chart-to-pdf/37099>\
**Category:** 📊 Plotly Python\
**Created:** [April 2, 2020, 11:27am UTC](https://community.plotly.com/t/convert-plotly-chart-to-pdf/37099 "2020-04-02T11:27:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ditsuhi](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@Ditsuhi](https://community.plotly.com/u/Ditsuhi)\
**Post date:** [April 2, 2020, 11:27am UTC](https://community.plotly.com/t/convert-plotly-chart-to-pdf/37099/1 "2020-04-02T11:27:58Z")

</div>

Hello,

I am trying to convert plotly chart to pdf in google colab, but it runs error.  
Could you please help?

Here is the code:

```auto
import plotly.graph_objects as go
import os

#%%

fig = go.Figure(go.Bar(

            x=[5, 16, 18],

            y=['Others', 'NO', 'YES'],

            orientation='h',

            text = [5, 16, 18],

            textposition='outside',

            width = 0.45           

   ))

#%%

fig.show()

#%%

if not os.path.exists("images"):

    os.mkdir("images")

#%%

fig.write_image("images/fig1.pdf")

```

Bests,  
Ditsuhi

---

<div class="post-metadata">

**Author:** ![Emmanuelle](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emmanuelle/32/7853_2.png) [@Emmanuelle](https://community.plotly.com/u/Emmanuelle)\
**Post date:** [April 2, 2020, 12:57pm UTC](https://community.plotly.com/t/convert-plotly-chart-to-pdf/37099/2 "2020-04-02T12:57:24Z")

</div>

Hi @Ditsuhi welcome to the forum! A solution is given in [https://stackoverflow.com/questions/57262385/saving-or-downloading-plotly-iplot-images-on-google-colaboratory/57272111#57272111](https://stackoverflow.com/questions/57262385/saving-or-downloading-plotly-iplot-images-on-google-colaboratory/57272111#57272111)

---

<div class="post-metadata">

**Author:** ![Ditsuhi](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@Ditsuhi](https://community.plotly.com/u/Ditsuhi)\
**Post date:** [April 2, 2020, 1:32pm UTC](https://community.plotly.com/t/convert-plotly-chart-to-pdf/37099/3 "2020-04-02T13:32:47Z")

</div>

Yeah, it works. Thank you so much.
