update to 0.0.4

157 views
Skip to first unread message

Paweł Bąk

unread,
Dec 19, 2012, 8:08:16 AM12/19/12
to xhtm...@googlegroups.com
I've updated xhtmlt2pdf from 0.0.3 to 0.0.4

xhtml2pdf                 - PDF generator using HTML and CSS
  INSTALLED: 0.0.4 (latest)

now i cant generate my pdf:

2128 def pdf(request):
2129     import StringIO
2130     from xhtml2pdf import pisa
2131     context = RequestContext(request)
2132     file_data = render_to_string(
2133             'template.html',
2134             context,
2135             )
2136     myfile = StringIO.StringIO()
2137     pisa.CreatePDF(file_data, myfile)
2138     response = HttpResponse(myfile.getvalue(), mimetype='application/pdf')
2139     response['Content-Disposition'] = 'attachment; filename=result.pdf'
2140     return response

my_template:

  1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2 "http://www.w3.org/TR/html4/loose.dtd">
  3 <html>
  4 <head>
  5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6 <title>Background</title>
  7 <style type='text/css'>
  8     @font-face {
  9         font-family: "DejaVuSans";
 10         src: url("DejaVuSans.ttf");
 11         }
 12     @page {
 13         margin-top: 3cm;
 14         margin-right: 2cm;
 15         margin-left: 2cm;
 16         margin-bottom: 3cm;
 17         background-image: url('pdf.pdf');
 18         @frame bar{
 19             -pdf-frame-content: bar;
 20             margin-top: 550px;
 21             margin-left: 300px;
 22         }
 23         @frame foo{
 24             -pdf-frame-content: foo;
 25             margin-top: 850px;
 26             margin-left: 400px;
 27         }                                                                                                         
 28         }
 29     @page page1 {
 30         background-image: url('background.pdf')
 31         }
 32
 33     html, body{
 34             font-family: "DejaVuSans";                                                                            
 35             padding: 0px;
 36             margin: 0px;
 37         }
 38     #foo {
 39         color: #4A252C;
 40         font-size: 25px;
 41     }      
 42     #bar {
 43         color: #4A252C;
 44         font-size: 20px;
 45     }  
 46 </style>
 47 </head>                                                                                                           
 48 <body>
 49     <div>
 50         <div id=foo>
 51             fooo
 52         </div>
 53         <div id=bar>
 54             bar
 55     </div>
 56     </div>
 57         <div>
 58     <pdf:nexttemplate name=page1/>
 59     <pdf:nextpage/>
 60     dasdaa
 61     </div> 
 62 </body>
 63 </html>


Error:

Exception Type: ValueError
Exception Value:
too many values to unpack

  2137.     pisa.CreatePDF(file_data, myfile)

/lib/python2.6/site-packages/xhtml2pdf/context.py" in atPage
  281.             fname, static, border, x, y, w, h = self._pisaAddFrame(name, data, first=True, border=pageBorder, size=c.pageSize)

Paweł Bąk

unread,
Dec 19, 2012, 9:08:09 AM12/19/12
to xhtm...@googlegroups.com

Thomas Kremmel

unread,
Feb 4, 2013, 8:15:11 AM2/4/13
to xhtm...@googlegroups.com
Thanks Pawel.
I just installed xhtml2pdf using pip. This installs the 0.0.4 version. Therefore I stumbled over the same issue.
Whereas I will use now the latest source code from github to overcome this issue, I want to ask whether there is already a release date, including this fix, planned for the next version?

Christopher Glass

unread,
Feb 4, 2013, 8:26:39 AM2/4/13
to xhtm...@googlegroups.com
Not really, but if I can quite easily push a new release out if that
would be a good thing (tm).
I don't have an enormous quantity of spare time these days, so it
would really help if somebody would step up and helped me with the
maintenance - I would really appreciate it.

- Chris
> --
> You received this message because you are subscribed to the Google Groups
> "Pisa XHTML2PDF Support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to xhtml2pdf+...@googlegroups.com.
>
> To post to this group, send email to xhtm...@googlegroups.com.
> Visit this group at http://groups.google.com/group/xhtml2pdf?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Thomas Kremmel

unread,
Feb 4, 2013, 9:04:08 AM2/4/13
to xhtm...@googlegroups.com
hi chris,

for me it looks like a lot of xhtml2pdf beginners will stumble over this bug. I actually just used the example from the readme in your django-xhtml2pdf lib, combined with the test_pdf provided here: https://github.com/chrisglass/django-xhtml2pdf/blob/master/django_xhtml2pdf/templates/test_pdf.html

Therefore I think it would be good to have a release date soon, including at least this fix.

I have quite a bit python / django experience, I used reportlab for my last project, and was looking now for a wrapper that helps me with the basic stuff, as I was not really happy dealing with the low-level api of reportlab. See also my SOF question related to this topic: http://stackoverflow.com/questions/14609182/reportlab-wrapper

I'm not a full-time web-developer, and as for the most uf us, also do not have a lot of spare time. Anyhow, I will try out the xhtml2pdf and django-xhtml2pdf as I really like the concept. Anyhow, looking at the complexity of the project, the time I would be able to devote, and my experience with your lib, I'm a bit scared that I will be much of use. I will also give https://github.com/matthiask/pdfdocument a try to see whether this project might fit my needs.

Thumbs up for the good work you provided. 

Jonathan Kennell

unread,
Mar 18, 2013, 6:21:42 PM3/18/13
to xhtm...@googlegroups.com
Yeah - would love to see a quick fix get pushed to easy_install.  If it's indeed a one line change, shouldn't take too long...
Reply all
Reply to author
Forward
0 new messages