# How to save output from GraphViz.jl to pdf?

**URL:** <https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476>\
**Category:** General Usage\
**Tags:** question, package, plotting\
**Created:** [May 22, 2022, 11:16pm UTC](https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476 "2022-05-22T23:16:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Norman](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@Norman](https://discourse.julialang.org/u/Norman)\
**Post date:** [May 22, 2022, 11:16pm UTC](https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476/1 "2022-05-22T23:16:56Z")

</div>

Hi,

Could someone show an example of printing the output generated from [GraphViz.jl](https://github.com/JuliaGraphs/GraphViz.jl) to a pdf file? Let’s say just use the example below. Thank you!

```julia
dot"""
graph graphname {
     // The label attribute can be used to change the label of a node
     a [label="Foo"];
     // Here, the node shape is changed.
     b [shape=box];
     // These edges both have different line properties
     a -- b -- c [color=blue];
     b -- d [style=dotted];
 }
"""

```

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [May 23, 2022, 9:21pm UTC](https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476/2 "2022-05-23T21:21:12Z")

</div>

```julia
using GraphViz, FileIO, Cairo
g =
dot"""
graph graphname {
     // The label attribute can be used to change the label of a node
     a [label="Foo"];
     // Here, the node shape is changed.
     b [shape=box];
     // These edges both have different line properties
     a -- b -- c [color=blue];
     b -- d [style=dotted];
 }
"""
FileIO.save("examplegraph.png", g)
FileIO.save("examplegraph.svg", g)

```

You can either convert the SVG or PNG file to PDF.

---

<div class="post-metadata">

**Author:** ![Norman](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@Norman](https://discourse.julialang.org/u/Norman)\
**Post date:** [May 23, 2022, 10:35pm UTC](https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476/3 "2022-05-23T22:35:24Z")

</div>

Thanks for the reply!

I initially thought there would be a way to directly generate a pdf from GraphViz. But, it seems that only SVG and PNG formats are implemented at this moment.

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [May 23, 2022, 10:40pm UTC](https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476/4 "2022-05-23T22:40:00Z")

</div>

> [@Norman](#):
>
> But, it seems that only SVG and PNG formats are implemented at this moment.

I thought that if the `ImageMagick` package was installed, one should be able to save the graph directly to a PDF file via the `FileIO.save` function. But `ImageMagick` encounters an error in this case. Perhaps it’s worth submitting an issue to either `FileIO`? (or `ImageMagick`?)

---

<div class="post-metadata">

**Author:** ![Norman](https://avatars.discourse-cdn.com/v4/letter/n/97f17d/32.png) [@Norman](https://discourse.julialang.org/u/Norman)\
**Post date:** [May 23, 2022, 10:47pm UTC](https://discourse.julialang.org/t/how-to-save-output-from-graphviz-jl-to-pdf/81476/5 "2022-05-23T22:47:12Z")

</div>

Yes, I guess I have to bother the package authors to take a look at this aspect.
