我正在将内存中的文档转换为 pdf (unoconv) 并在终端中打印 (pdftotext):
unoconv -f pdf --stdout sample.doc | pdftotext -layout -enc UTF-8 - out.txt
正在工作中。现在我想使用这个命令child_process.spawn
:
let filePath = "...",
process = child_process.spawn("unoconv", [
"-f",
"pdf",
"--stdout",
filePath,
"|",
"pdftotext",
"-layout",
"-enc",
"UTF-8",
"-",
"-"
]);
在这种情况下,只有第一个命令(| 之前)有效。我可以做我正在尝试的事情吗?
谢谢。
更新-
的结果:sh -c- ....
bash-3.2$ sh -c- unoconv -f pdf --stdout /Users/fatimaalves/DEV/xx/_input/sample.doc | pdftotext -layout -enc UTF-8 - -
sh: --: invalid option
Usage: sh [GNU long option] [option] ...
sh [GNU long option] [option] script-file ...
GNU long options:
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noediting
--noprofile
--norc
--posix
--protected
--rcfile
--restricted
--verbose
--version
--wordexp
Shell options:
-irsD or -c command or -O shopt_option (invocation only)
-abefhkmnptuvxBCHP or -o option
Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table