[poppler] poppler.document_new_from_data usage

Albert Astals Cid aacid at kde.org
Mon Dec 29 15:39:12 PST 2008


A Dissabte 27 Desembre 2008, Carl Karsten va escriure:
> I am trying to convert pdf to image in python to make thumbnails of a pdf
> that can be displayed on a web page.  I think the poppler python bindings
> will do it,
> but I am pretty sure I am missing something.

As said on IRC we (the poppler team) do not maintain the python bindings, 
though probably the person that does reads the list.

Obviosuly "the argument 1 must be string without null bytes" problem is a bug 
either in the python binding or in the glib binding the python sits on top 
of.

Albert

>
> Given this failed attempt, can someone strighten it out?
>
> #!/usr/bin/python
> # p2i.py
> # test of converting a pdf to an image.
>
> import poppler
> import gtk
>
> # there isn't really a pdf file on disk.
> # pdf comes from mkpdf(), but this makes it easier to test.
> pdf=open('foo.pdf','rb').read()
>
> # I do this to avoid
> # TypeError: document_new_from_data() argument 1 must be string without
> null bytes, not str
> # which is probably an indication I am already lost.
> pdf=(pdf.replace('\x00','a')
>
> p = poppler.document_new_from_data(pdf,len(pdf),'')
> p0=p.get_page(0)
>
> pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,300,300)
>
> pb=p0.render_to_pixbuf(0,0,8,11,1,0,pixbuf)
>
> # Error (40155): Unknown operator 'e'
>
>
> Carl K
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler




More information about the poppler mailing list