views:

244

answers:

1

The following code prints an empty line as an output which is false. The problem is not in the permissions, since I tested the command with 777 permissions for the pdf -file. How can you fix the command to give a right output?

import subprocess
from subprocess import PIPE, Popen
output = Popen(['pdftotext', '/home/aal/Desktop/lkn_pdf/appa.pdf'], stdout=PIPE).communicate()[0]
+3  A: 

pdftotext creates a file by default. To send the result to standard output, use:

pdftotext file.pdf -

or in Python:

output = Popen(['pdftotext', '/home/aal/Desktop/lkn_pdf/appa.pdf', '-'], stdout=PIPE).communicate()[0]
interjay