8

私はドキュメントをメモリ内の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
4

2 に答える 2