", line 1, in AttributeError:...">

Bug #1163236 “pypoppler shouldn't always require X11 to be runni...” : Bugs : Poppler Python Bindings (original) (raw)

TL;DR: I believe the following should work when the DISPLAY environment variable is unset, but it doesn't appear to.

$ python -c 'import poppler; d=poppler.document_new_from_file("file:///path/to/file.pdf", None); print d.get_n_pages()'
10
$ DISPLAY= python -c 'import poppler; d=poppler.document_new_from_file("file:///path/to/file.pdf", None); print d.get_n_pages()'
ImportError: could not import gtk.gdk
Traceback (most recent call last):
File "", line 1, in
AttributeError: '__main__.PopplerDocument' object has no attribute 'get_n_pages'

At the moment, using pypoppler to do anything useful requires X to be running - this shouldn't be a hard requirement. For example, the program pdftotext (part of poppler) doesn't require X running to extract text from PDF files -- why should pypoppler?

The knock-on effect is that AFAICS pypoppler can't currently be easily used as a server-side process to handle PDF files.

$ rpm -q python pypoppler
python-2.7.3-13.fc18.x86_64
pypoppler-0.12.1-22.fc18.x86_64