ARTICLE AD BOX
I have an Elixir module in which I am trying to call out to Pdfcpu to modify existing PDFs. Pdfcpu is written in Go and has a CLI and an API, and I am trying to use the API. I am using Wasmex to run the WASM code and interface with Elixir.
I have created a simple Go module:
package main import ( "log" "github.com/pdfcpu/pdfcpu/pkg/api" ) func main() { } func RotateFile(inFile, outFile string, rotation int, selectedPages []string) { if err := api.RotateFile(inFile, outFile, rotation, []string{"1"}, nil); err != nil { log.Fatal(err) } }then ran
go mod init proj/pdfcpu go get github.com/pdfcpu/pdfcpu@latest go mod tidy GOOS=wasip1 GOARCH=wasm go build -o main.goTo test, I ran a simple Elixir script
api_binary = File.read!("main.wasm") {:ok, api_pid} = Wasmex.start_link(%{bytes: api_binary, wasi: true}) Wasmex.call_function(api_pid, "RotateFile", ["input.pdf", "output.pdf", 180, [], nil])And I receive {:error, "exported function `RotateFile` not found"}
RotateFile is in the api package, so I tried calling "api.RotateFile" instead of "RotateFile", but it made no difference.
What am I doing wrong?
