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)