-
|
I am using this package to render pdf docs from a webserver. For the webserver i don't want to install typst on there so im i was wondering, if its possible to use a docker container to run the compiles. I need to compile a doc with added values like in the following example: https://github.com/Dadido3/go-typst/tree/main/examples/passing-values All help and ideas appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
|
Hi, it's already on my to do list, but i haven't got around implementing Docker support. I may have something ready in a few days or so, as it shouldn't be too hard to do. It's basically just another way to invoke the docker executable. |
Beta Was this translation helpful? Give feedback.
-
|
Hey Dadido, thanks for the quick reply, I'll be happy of you give me a short example. Wonderful package you made there 👌🏼 |
Beta Was this translation helpful? Give feedback.
-
|
Alright, i updated this module, and it now supports the official Typst Docker image besides other improvement. Make sure you are using package main
import (
"bytes"
"log"
"os"
"github.com/Dadido3/go-typst"
)
func main() {
markup := bytes.NewBufferString(`= Hello world`)
// Compile the prepared markup with Typst and write the result it into `output.pdf`.
f, err := os.Create("output.pdf")
if err != nil {
log.Panicf("Failed to create output file: %v.", err)
}
defer f.Close()
typstCaller := typst.Docker{}
if err := typstCaller.Compile(markup, f, nil); err != nil {
log.Panic("failed to compile document: %w", err)
}
}This should create a new PDF document with the text "Hello World". I also updated the README.md with everything you may need when running the Docker variant. Feel free to write back if you encounter any other issues or problems. As the code is pretty new and untested (besides the unit tests). There may be bugs or rough edges. |
Beta Was this translation helpful? Give feedback.
-
|
The new package is working perfectly. is there a chance to also run this against an already running container (for example deployed via docker compose)? in theory the commands should only be changed to docker exec instead of run? Thanks again for the great work. |
Beta Was this translation helpful? Give feedback.
Alright, i updated this module, and it now supports the official Typst Docker image besides other improvement. Make sure you are using
go-typst 0.7.0; then you can just run this to check if everything works correctly: