# Preview of multiple pages document in VS code using Typstry.jl

**URL:** https://discourse.julialang.org/t/preview-of-multiple-pages-document-in-vs-code-using-typstry-jl/137974
**Category:** General Usage
**Created:** [July 6, 2026, 5:00pm UTC](https://discourse.julialang.org/t/preview-of-multiple-pages-document-in-vs-code-using-typstry-jl/137974 "2026-07-06T17:00:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![vzion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vzion/32/44768_2.png) [@vzion](https://discourse.julialang.org/u/vzion)
#### Post date: [July 6, 2026, 5:00pm UTC](https://discourse.julialang.org/t/preview-of-multiple-pages-document-in-vs-code-using-typstry-jl/137974/1 "2026-07-06T17:00:33Z")

</div>

I’m looking for a way to deal with multiple pages preview when using Typstry.jl in VS code with the Julia extension (using PrettyTables typst backend in this example just for fun).

```julia
# Init
using Typstry, PrettyTables, DataFrames
io = IOBuffer()
pretty_table(io,DataFrame(a=1:15),backend = :typst)
pt_df = String(take!(io))

```

If I create a single “A4” page document with height:auto, I can see the preview in the Julia Plots but the generated PDF will be an unusable single page document :

```julia
single_page_doc = TypstString(TypstText("""
#set page("a4", height:auto)
$pt_df
#lorem(500)
"""))
render(single_page_doc;input="ok.typ",output="ok.pdf",open=false)

```

If I want a document with more than 1 page (without height: auto), there’s no preview of the document in Julia Plots since a TypstCommandError is thrown, but the PDF will be fine with multiple pages :

```julia
# ERROR: TypstCommandError: failed to run a `TypstCommand (["compile", "--font-path", "....julia/artifacts/...", "--format", "png", "-", "-"])
multiple_page_doc = TypstString(TypstText("""
#set page("a4")
$pt_df
#lorem(500)
"""))
render(multiple_page_doc;input="bug.typ",output="bug.pdf",open=false)

```

So now I’m setting the page’s height to auto to have a preview and remove it when I want to render the final PDF…  
Is there a better way to have a multiple page preview working using Typstry.jl in VS code without using other typst extension ?

---

<div class="post-metadata">

### Author: ![technocrat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/technocrat/32/220947_2.png) [@technocrat](https://discourse.julialang.org/u/technocrat)
#### Post date: [July 6, 2026, 7:51pm UTC](https://discourse.julialang.org/t/preview-of-multiple-pages-document-in-vs-code-using-typstry-jl/137974/2 "2026-07-06T19:51:37Z")

</div>

VSCode does this natively using a terminal emulator. Not all support graphic rendering in the first place and AFAIK none of those that do are able to cope reliably with multipage images. The pdf comes in as stdio in a `l o o o n g` string. stream of pixels so the buffer gets clobbered. I’ve heard tell that Some terminals implement protocols that enable direct image rendering. Some terminals implement protocols that enable direct image rendering. I’ve seen reports that VSCode extensions like PDF Viewer (by mathematic) or PDF Preview embed Mozilla’s pdf.js library right into the IDE. This gives you a native-feeling PDF reader with full layout controls, a sidebar index, smooth scrolling, and text highlighting, completely bypassing the terminal’s limitations. For my money if composing in VSCode or another IDE running a Typst `watch` command is the process to display on save in a different window is the way to go.

---

<div class="post-metadata">

### Author: ![jakobjpeters](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobjpeters/32/207797_2.png) [@jakobjpeters](https://discourse.julialang.org/u/jakobjpeters)
#### Post date: [July 7, 2026, 4:50am UTC](https://discourse.julialang.org/t/preview-of-multiple-pages-document-in-vs-code-using-typstry-jl/137974/3 "2026-07-07T04:50:06Z")

</div>

Hi there! I ran the code you provided in a new environment and am unable to reproduce the error. Would you be able to provide a script that produces the error you describe? I’m happy to help 🙂

```julia-repl
(@v1.12) pkg> activate --temp
  Activating new project at `/tmp/jl_wpoM7S`

(jl_wpoM7S) pkg> add Typstry, DataFrames, PrettyTables
   Resolving package versions...
    Updating `/tmp/jl_wpoM7S/Project.toml`
    ...

julia> using Typstry, PrettyTables, DataFrames

julia> io = IOBuffer();

julia> pretty_table(io,DataFrame(a=1:15),backend = :typst)

julia> pt_df = String(take!(io));

julia> single_page_doc = TypstString(TypstText("""
       #set page("a4", height:auto)
       $pt_df
       #lorem(500)
       """));

julia> render(single_page_doc;input="ok.typ",output="ok.pdf",open=false)

julia> multiple_page_doc = TypstString(TypstText("""
       #set page("a4")
       $pt_df
       #lorem(500)
       """));

# this did not error for me
julia> render(multiple_page_doc;input="bug.typ",output="bug.pdf",open=false)

```

---

<div class="post-metadata">

### Author: ![jakobjpeters](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobjpeters/32/207797_2.png) [@jakobjpeters](https://discourse.julialang.org/u/jakobjpeters)
#### Post date: [July 7, 2026, 4:52am UTC](https://discourse.julialang.org/t/preview-of-multiple-pages-document-in-vs-code-using-typstry-jl/137974/4 "2026-07-07T04:52:43Z")

</div>

> but the PDF will be fine with multiple pages

Oh, is it that the PDF renders (as my attempt shows) but some other environment throws the error? Could you elaborate on that? I do not use VSCode and do not know where to look.

---

<div class="post-metadata">

### Author: ![vzion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vzion/32/44768_2.png) [@vzion](https://discourse.julialang.org/u/vzion)
#### Post date: [July 7, 2026, 1:37pm UTC](https://discourse.julialang.org/t/preview-of-multiple-pages-document-in-vs-code-using-typstry-jl/137974/5 "2026-07-07T13:37:46Z")

</div>

I think I’ve understand what the problem is.

The error is not thrown when rendering the pdf but when VSC tries to display a preview of a TypstString of a multipage document using the Typstry.jl \> utilities.jl \> _show\_render()_ function.  
This function tries to compile a png (that will be used as a preview of the document) using a TypstCommand equivalent to this :

```julia-auto
run(typst`compile multipage.typ --format png`)

```

… when a multipage document should be compiled to png with a page number template in the output path or given a specific page :

```julia-auto
run(typst`compile multipage.typ {p}-{t}.png --format png`)
run(typst`compile multipage.typ --format png --pages 1`)

```

To summarise, VS code preview works fine with a singlepage document by using this command in show\_render :

```julia-auto
single_page_doc = TypstString(TypstText("""
#set page("a4", height:auto) 
#lorem(1000)
"""))
write("singlepage.typ",single_page_doc)
run(typst`compile singlepage.typ --format png`) # generate a multipage.png correctly

```

But when using the same command for a multipage document, an `error: cannot export multiple images without a page number template ({p}, {0p}) in the output path` is thrown, and no png preview is generated :

```julia-auto
multiple_page_doc = TypstString(TypstText("""
#set page("a4")
#lorem(1000)
"""))

write("multipage.typ",multiple_page_doc)
run(typst`compile multipage.typ --format png`) # TypstComandError : failed to run with typst error : cannot export multiple images without a page number template ({p}, {0p}) in the output path

# where these command works fine for multipage document
run(typst`compile multipage.typ --format png --pages 1`) # 1-1.png generated
run(typst`compile multipage.typ {p}-{t}.png --format png`) # 1-2.png and 2-2.png generated

```

---

<div class="post-metadata">

### Author: ![jakobjpeters](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobjpeters/32/207797_2.png) [@jakobjpeters](https://discourse.julialang.org/u/jakobjpeters)
#### Post date: [July 11, 2026, 8:37am UTC](https://discourse.julialang.org/t/preview-of-multiple-pages-document-in-vs-code-using-typstry-jl/137974/6 "2026-07-11T08:37:16Z")

</div>

Thank you for investigating further! I can reproduce with your example and using `render` and a `png` output file. v0.7.0 switched to use `stdin` and `stdout` instead of writing to a file ([source](https://github.com/jakobjpeters/Typstry.jl/blob/v0.7.0/src/strings/utilities.jl#L164-L166)). This method is used by `show(::IO, ::MIME, ::T)`. Since the data must be written to the `IO`, the support for multiple pages is strictly dependent on the format. That is, it can render a multi-page PDF but not PNG or SVG because those formats fundamentally require multiple files.

I believe you can correctly generate a multi-page PDF. Could you try to install an extension that supports those, such as [vscode-pdf](https://marketplace.visualstudio.com/items?itemName=tomoki1207.pdf)? I would suggest inquiring with the Julia VSCode extension about multi-page PDF support.
