Generating pdf in python with pisa

1,311 views
Skip to first unread message

Mukesh Yadav

unread,
Nov 18, 2012, 1:34:10 AM11/18/12
to mu...@googlegroups.com
Hi, 
  I want to generate pdf from html files, I installed reportlab and pisa via apt-get. 

I can generate pdf via command line with this command 

$ xhtml2pdf -s http://www.google.com/

but I'm not able to import xhtml2pdf in python file.

import ho.xhtml2pdf as xhtml2pdf
or 
import xhtml2pdf.pisa as pisa


i get error 

ImportError: No module named xhtml2pdf.pisa
or 
ImportError: No module named 
xhtml2pdf




--
Regards
Mukesh Yadav

Devendra Rane

unread,
Nov 18, 2012, 2:57:02 AM11/18/12
to mu...@googlegroups.com
Use this :

import ho.pisa as pisa

mypdf = pisa.CreatePDF(<html_string>, file('myfile.pdf', "wb"))


/dev/
Devendra K. Rane
Ph: +91 900 403 8889
Skype: ranedk
Gtalk: ranedk







--
Regards
Mukesh Yadav

--
_________________________________________________
Mumbai Python Users Group - http://www.mumpy.org/
Mailing Group - http://groups.google.com/group/mumpy/
Membership Management - http://groups.google.com/group/mumpy/subscribe/

Gaurav Toshniwal

unread,
Nov 18, 2012, 3:32:19 AM11/18/12
to mu...@googlegroups.com

Can it be done using qtwebkit?

Mukesh Yadav

unread,
Nov 18, 2012, 5:38:18 AM11/18/12
to mu...@googlegroups.com

import ho.pisa as pisa
 

getting 

ImportError: No module named ho.pisa 

Devendra Rane

unread,
Nov 21, 2012, 3:43:37 AM11/21/12
to mu...@googlegroups.com
you need to install python-pisa

/dev/
Devendra K. Rane
Ph: +91 900 403 8889
Skype: ranedk
Gtalk: ranedk



--

Krishnakant Mane

unread,
Nov 21, 2012, 7:29:41 AM11/21/12
to mu...@googlegroups.com, Devendra Rane
Hello Mukesh,
Did you try reportlab?
Happy hacking.
Krishnakant.

Raxit Sheth

unread,
Nov 21, 2012, 9:41:22 AM11/21/12
to mu...@googlegroups.com
Dont know you are still stuck ? Reading mail bit late, can add me to
gtalk if yet not found any sol

Raxit

Raxit Sheth

unread,
Nov 21, 2012, 9:54:33 AM11/21/12
to mu...@googlegroups.com
i just done the same thing! installed and able to import.

Let me know where you got stuck, if you follow instructions from
here, http://pypi.python.org/pypi/xhtml2pdf/#downloads
it is just straight fwd (you can ignore virtual env stuff, i have ignored that)

Raxit

Raxit Sheth

unread,
Nov 21, 2012, 9:55:16 AM11/21/12
to mu...@googlegroups.com
raxit@raxit-Lenovo-G570:~/xhtml2pdf$ python
Python 2.7.1+ (r271:86832, Sep 27 2012, 21:16:52)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xhtml2pdf

Dhruv Baldawa

unread,
Nov 22, 2012, 12:53:25 AM11/22/12
to mu...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages