I am trying to pass a file name into my JavaScript script, similarly to the example code here: https://mupdf.com/docs/examples/draw-document.js
C:\Tools\mupdf-1.14.0-windows> .\mutool.exe run .\script.js c:\temp\test.pdf
Unfortunately, I'm getting the following error:
ReferenceError:
'argv'
is not defined
The documentation (https://mupdf.com/docs/manual-mutool-run.html) says:
[...] the command line arguments are accessible from the global 'argv' object.
The underlying code looks like this (this is just 'proof of concept' code):
var doc = new Document(argv[1]);
var outline = doc.loadOutline();
var outlineString = JSON.stringify(outline, {}, 2);
var txt = new ActiveXObject("Scripting.FileSystemObject");
var s = txt.CreateTextFile("c:\\temp\\text.json", true);
s.Write(outlineString);
s.Close();
Could someone point out the error I'm making please?
Just to point out that in a perfect world, I'd like to convert the JSON object to an XML file.
From the MuTool 1.14.0-rc1 Changelog:
- mutool run: Pass arguments to script in scriptArgs global.
So, you should use scriptArgs
rather than argv
in your script.
Cheers, Rom