August 2015: under new lighting in Windows 7, the problem remains the same:
Poppler.Document.new_from_data(data, len(data), None)
returns: Type error: there should be strings, not bytes.
Poppler.Document.new_from_data(str(data), len(data), None)
returns: the PDF document is corrupted (4).
I could not use this function.
I tried using NamedTemporayFile instead of a file on disk, but for some unknown reason it returns an unknown error.
Therefore, I am using a temporary file. Not the most beautiful way, but it works.
Here is the test code for Python 3.4, if anyone has an idea:
from gi.repository import Poppler import tempfile, urllib from urllib.parse import urlparse from urllib.request import urljoin testfile = "d:/Mes Documents/en cours/PdfBooklet3/tempfiles/preview.pdf" document = Poppler.Document.new_from_file("file:///" + testfile, None)
Dysmas
source share