# Show PDF in Julia Notebook & general advises for for jupyterlab extensions

**URL:** <https://discourse.julialang.org/t/show-pdf-in-julia-notebook-general-advises-for-for-jupyterlab-extensions/39466>\
**Category:** Teaching & Outreach\
**Created:** [May 14, 2020, 1:49pm UTC](https://discourse.julialang.org/t/show-pdf-in-julia-notebook-general-advises-for-for-jupyterlab-extensions/39466 "2020-05-14T13:49:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![koehlerson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/koehlerson/32/13108_2.png) [@koehlerson](https://discourse.julialang.org/u/koehlerson)\
**Post date:** [May 14, 2020, 1:49pm UTC](https://discourse.julialang.org/t/show-pdf-in-julia-notebook-general-advises-for-for-jupyterlab-extensions/39466/1 "2020-05-14T13:49:43Z")

</div>

Hey there,

I prepared a JupyterHub Server for a class and I converted old exercise material from matlab into beautiful julia notebooks. Unfortunately, I haven’t found any possibility to view PDF images in the notebook. Is there something similar for the Julia kernel like this: [python - View pdf image in an iPython Notebook - Stack Overflow](https://stackoverflow.com/questions/19470099/view-pdf-image-in-an-ipython-notebook) ? I need this in order to get rid of the separately prepared latex documents. Final goal is to just export the notebooks as PDFs.

Besides that, do you have any advises regarding extensions? Do you use something like nbgrader for classes? Do you have any extension installed which was a game changer for teaching?

Edit: current workaround is to include svg as html img, however it’s very unlikely that I will have svgs from all figures I want to include.

Thanks and cheers,  
Max

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 14, 2020, 3:55pm UTC](https://discourse.julialang.org/t/show-pdf-in-julia-notebook-general-advises-for-for-jupyterlab-extensions/39466/2 "2020-05-14T15:55:49Z")

</div>

You can convert them to SVG, and then show SVG inline in the notebook. `PGFPlotsX` has a converter function (which calls `pdf2svg` I believe, so you have to have that installed).

```julia
using PGFPlotsX

# Create a PDF
x = range(0.0, 2pi; length=100)
y = sin.(x)
p = @pgf Axis({}, Plot({}, Coordinates(x, y)))
PGFPlotsX.save("sin.pdf", p)

# Create a PDF struct that can be showed as inline svg
struct PDF
    file::String
    PDF(file) = new(abspath(file))
end
function Base.show(io::IO, ::MIME"image/svg+xml", pdf::PDF)
    svg = first(splitext(pdf.file)) * ".svg"
    PGFPlotsX.convert_pdf_to_svg(pdf.file, svg)
    write(io, read(svg))
    try; rm(svg; force=true); catch e; end
    return nothing
end

PDF("sin.pdf")

```

> [@koehlerson](#):
>
> Do you use something like nbgrader for classes?

I have not used it, but IIRC @mbauman has at least experimented with it.

---

<div class="post-metadata">

**Author:** ![koehlerson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/koehlerson/32/13108_2.png) [@koehlerson](https://discourse.julialang.org/u/koehlerson)\
**Post date:** [May 15, 2020, 11:27am UTC](https://discourse.julialang.org/t/show-pdf-in-julia-notebook-general-advises-for-for-jupyterlab-extensions/39466/3 "2020-05-15T11:27:02Z")

</div>

I just tried it and it works 🙂 Thank you very much Fredrik!
