Thanks a lot, however, I waste my time trying using the packages EVINCE AND POPPLER DOESNT WORK I get this error:
"AttributeError: 'gi.repository.Poppler' object has no attribute 'document_new_from_file'"
MY CODE
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk,Gdk,Pango
from gi.repository import Poppler
Poppler.document_new_from_file("D:/1.pdf", None)
EVINCE doesnt work too, I get this error:
«C:\Python34\lib\evince\4\backends»: No such file or directoryss
(python.exe:8920): EvinceDocument-WARNING **: Error opening directory “C:\Python34\lib\evince\4\backends”: No such file or directory
Traceback (most recent call last):
File "D:\SISTEMAS INFORMATICOS\REPORTES PYTHON\reportes.py", line 17, in on_activate
doc = EvinceDocument.Document.factory_get_document('D:/1.pdf')
GLib.Error: ev-document-error-quark: El tipo de archivo (unknown) (application/octet-stream) no está soportado (0)
MY CODE
from gi.repository import Gtk, Gio
from gi.repository import EvinceDocument
from gi.repository import EvinceView
class HelloWorldApp(Gtk.Application):
def init(self):
Gtk.Application.init(self, application_id="apps.test.helloevince", flags=Gio.ApplicationFlags.FLAGS_NONE)
self.connect("activate", self.on_activate)
for poppler, do you mean Poppler.Document.new_from_file() ? document_new_from_file is the C function, please see docs.
About evince it looks like it's not properly relocatable I will fix it in next revision, thanks! As workaround try re-run with current directory: C:\Python34\lib\site-packages\gnome
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for answer me, yes, I commited a mistake with Poppler, may you give some documentation of Poppler in gtk3 with python?, but I fixed my mistake and after many many hours, I achieved show my pdf file in my python program. There is not information about Poppler in windows, even I wasted a lot of time trying to find a correct URI for windows,the correct URI is "file:///D:/file.pdf", with "D:/file.pdf" I got error.
About Evince, I copied all directories from C:\Python34\lib\evince\4\backends to C:\python34\Lib, however it does not work yet, it would be so good if we could have evince in our windows gtk environment.
Thanks for your work, Python is a beautiful language, and is a gift have it in windows with a powerful gui framework like Gtk3, with a easy installation. Greetings from Perú.
Last edit: Luis Alcantara 2017-06-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
errr I'm not YOUR TEACHER, FYI I have tested poppler in python since I included it in the first release!!! and the issue with Evince is not mine either it was most likely an ambiguous assumption by upstream developer. I'm reluctant to include application oriented thing like evince, people should use poppler or gepub and COOK their code. not use high level library like evince.
btw thanks for your review (sarcasm) at homepage.
the docs is included in installer!
Last edit: tumagonx 2017-06-24
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks a lot, however, I waste my time trying using the packages EVINCE AND POPPLER DOESNT WORK I get this error:
"AttributeError: 'gi.repository.Poppler' object has no attribute 'document_new_from_file'"
MY CODE
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk,Gdk,Pango
from gi.repository import Poppler
Poppler.document_new_from_file("D:/1.pdf", None)
EVINCE doesnt work too, I get this error:
«C:\Python34\lib\evince\4\backends»: No such file or directoryss
(python.exe:8920): EvinceDocument-WARNING **: Error opening directory “C:\Python34\lib\evince\4\backends”: No such file or directory
Traceback (most recent call last):
File "D:\SISTEMAS INFORMATICOS\REPORTES PYTHON\reportes.py", line 17, in on_activate
doc = EvinceDocument.Document.factory_get_document('D:/1.pdf')
GLib.Error: ev-document-error-quark: El tipo de archivo (unknown) (application/octet-stream) no está soportado (0)
MY CODE
from gi.repository import Gtk, Gio
from gi.repository import EvinceDocument
from gi.repository import EvinceView
class HelloWorldApp(Gtk.Application):
def init(self):
Gtk.Application.init(self, application_id="apps.test.helloevince", flags=Gio.ApplicationFlags.FLAGS_NONE)
self.connect("activate", self.on_activate)
def on_activate(self, data=None):
window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL)
window.set_title("Evince Gtk3 Python Example")
window.set_border_width(24)
scroll = Gtk.ScrolledWindow()
window.add(scroll)
EvinceDocument.init()
doc = EvinceDocument.Document.factory_get_document('D:/1.pdf')
view = EvinceView.View()
model = EvinceView.DocumentModel()
model.set_document(doc)
view.set_model(model)
scroll.add(view)
window.show_all()
self.add_window(window)
if name == "main":
app = HelloWorldApp()
app.run(None)
for poppler, do you mean Poppler.Document.new_from_file() ? document_new_from_file is the C function, please see docs.
About evince it looks like it's not properly relocatable I will fix it in next revision, thanks! As workaround try re-run with current directory: C:\Python34\lib\site-packages\gnome
Don't forget use proper URI for file path.
Thanks for answer me, yes, I commited a mistake with Poppler, may you give some documentation of Poppler in gtk3 with python?, but I fixed my mistake and after many many hours, I achieved show my pdf file in my python program. There is not information about Poppler in windows, even I wasted a lot of time trying to find a correct URI for windows,the correct URI is "file:///D:/file.pdf", with "D:/file.pdf" I got error.
About Evince, I copied all directories from C:\Python34\lib\evince\4\backends to C:\python34\Lib, however it does not work yet, it would be so good if we could have evince in our windows gtk environment.
Thanks for your work, Python is a beautiful language, and is a gift have it in windows with a powerful gui framework like Gtk3, with a easy installation. Greetings from Perú.
Last edit: Luis Alcantara 2017-06-23
errr I'm not YOUR TEACHER, FYI I have tested poppler in python since I included it in the first release!!! and the issue with Evince is not mine either it was most likely an ambiguous assumption by upstream developer. I'm reluctant to include application oriented thing like evince, people should use poppler or gepub and COOK their code. not use high level library like evince.
btw thanks for your review (sarcasm) at homepage.
the docs is included in installer!
Last edit: tumagonx 2017-06-24