Skip to content

Support for --to pdf Pandoc Format #11

@njg4ne

Description

@njg4ne

Describe the bug
Trying to convert --from a supported input type such as odt odt-test.odt --to the pdf type causes a WASI Error: [WASI stderr] pdflatex: runInteractiveProcess: unsupported operation (Operation is not supported)

To Reproduce
Building on the example vanilla JS code, if you add a temp directory for pandoc to put latex and whatever intermediaries it wants,

const tmp_dir = new PreopenDirectory("/tmp", []); // Create /tmp directory
const fds = [
  new OpenFile(new File(new Uint8Array(), { readonly: true })),
  ConsoleStdout.lineBuffered((msg) => console.log(`[WASI stdout] ${msg}`)),
  ConsoleStdout.lineBuffered((msg) => console.warn(`[WASI stderr] ${msg}`)),
  new PreopenDirectory("/", [
    ["in", in_file],
    ["out", out_file],
  ]),
  tmp_dir, // provide a temp directory for intermediary files
];

And then in the pandoc function you set the input file's data from a file upload rather than a text encoder,

in_file.data = new Uint8Array(await web_file.arrayBuffer());

Pandoc seems to have trouble even looking for a pdflatex executable, which it typically depends on for pdf conversions on the desktop app. I am wondering if the WASI issue were worked out, maybe it could use a latex like SwiftLaTeX's pdftex.wasm or busytex inside the WASI sandbox and get a successful PDF output.

Expected behavior
runInteractiveProcess would look for a binary in the WASI sandbox called pdflatex, which the developer would be expected to provide. At a minimum, maybe latex-involving conversions are added to the list of not supported for the WASM target (e.g. as with lua filters).

Environment

Additional context
I suppose this might be a WASM/WASI issue or maybe a @bjorn3/browser_wasi_shim issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions