2
$\begingroup$

There is RunThrough which captures the output and evaluates it. However, I would like the output as String. Is there a direct way without redirecting to temporary files etc.? Here is the code:

pdftohtml = "pdftohtml.exe";
pdf = "test.pdf";
ans = RunThrough[pdftohtml <> " -stdout " <> pdf, ""];

This fails with the error message

Syntax::sntx: Invalid syntax in or before 
"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">".

Is there a way to get to the output without evaluating it?

$\endgroup$
  • 1
    $\begingroup$ Does StringJoin@ReadList["!"<>pdftohtml <> " -stdout " <> pdf, Character] work? $\endgroup$ – yohbs Apr 20 '17 at 14:10
  • $\begingroup$ Or RunProcess[pdftohtml <> " -stdout " <> pdf, "StandardOutput"]? $\endgroup$ – yohbs Apr 20 '17 at 14:16
  • $\begingroup$ Thanks I will try this tomorrow $\endgroup$ – Karsten W. Apr 20 '17 at 15:21
  • $\begingroup$ RunProcess may need the list form (see docs) RunProcess[{pdftohtml,"-stdout",pdf},"StandardOutput"] $\endgroup$ – george2079 Apr 20 '17 at 20:08
  • $\begingroup$ @yohbs: the first construct StringJoin... works perfectly. Please make that an answer, and I will gladly upvote & accept... $\endgroup$ – Karsten W. Apr 21 '17 at 12:49
3
$\begingroup$
StringJoin@ReadList["!"<>pdftohtml <> " -stdout " <> pdf, Character]

Or

RunProcess[{pdftohtml," -stdout ",pdf}, "StandardOutput"]
$\endgroup$
  • $\begingroup$ The second command did not work for me, but the first one is a life saver! $\endgroup$ – Karsten W. Apr 21 '17 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.