Questions tagged [xhtml2pdf]

xhtml2pdf is a html2pdf converter using the ReportLab Toolkit, the HTML5lib and pyPdf. It supports HTML 5 and CSS 2.1 (and some of CSS 3). It is completely written in pure Python so it is platform independent.

240 questions
17
votes
4 answers

Django/Python: generate pdf with the proper language

I use Pisa/xhtml2pdf in my Django apps to generate pdf from an HTML source. That is: I generate the HTML file formatted with all 'printing' stuffs (e.g. page-breaks, header, footer, etc.) I convert this HTML into pdf using Pisa This process is ok…
Don
  • 16,928
  • 12
  • 63
  • 101
16
votes
4 answers

Convert html to pdf using Python/Flask

I want to generate pdf file from html using Python + Flask. To do this, I use xhtml2pdf. Here is my code: def main(): pdf = StringIO() pdf = create_pdf(render_template('cvTemplate.html', user=user)) pdf_out = pdf.getvalue() response…
Dmitry_Mahrachev
  • 279
  • 1
  • 2
  • 8
13
votes
5 answers

AttributeError: 'NoneType' object has no attribute 'app'

The below code gives error: Traceback (most recent call last): File "pdf.py", line 14, in create_pdf(render_template('templates.htm')) File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 123, in render_template …
user2499707
  • 155
  • 1
  • 1
  • 8
11
votes
1 answer

xhtml2pdf ImportError - Django

I installed xhtml2pdf using pip for use with Django. I am getting the following ImportError: Reportlab Toolkit Version 2.2 or higher needed But I have reportlab 3.0 >>> import reportlab >>> print reportlab.Version …
hanleyhansen
  • 6,304
  • 8
  • 37
  • 73
9
votes
1 answer

Pisa pdf converter is very slow with large tables

I'm using Pisa to convert HTML to PDF (in a Django project). It is very slow when handling tables that span over multiple pages: a 200-rows table takes up to 150 seconds to be converted, while it takes 15 seconds if I split it into smaller…
Don
  • 16,928
  • 12
  • 63
  • 101
8
votes
3 answers

Text inside the table cell improperly aligned

I'm using xhtml2pdf (former pisa, or is it vice versa? :)) to generate PDF from the django template. The template is rendered ok, but PDF I get from that template is corrupted in a very weird manner: text in table cells are lifted to the top of the…
J0HN
  • 26,063
  • 5
  • 54
  • 85
7
votes
2 answers

Generate multiple PDFs and zip them for download, all in a single view

I am using xhtml2pdf to generate PDFs in my Django View. The idea is to loop over all the instances that are there in the query, then for each instance create a PDF, then add all the generated PDFs to one zip File for download. The xtml2pdf logic is…
Abedy
  • 361
  • 5
  • 17
7
votes
5 answers

"Need a valid file name!" xhtml2pdf with Django

My problem is: I am creating a pdf file from an html, using the xhtml2pdf library. Having created the pdf file, I send the file to the user via email using the sendgrid API. However, I am not able to leave an image embedded in the pdf file, since…
Eli
  • 71
  • 1
  • 4
7
votes
1 answer

Django - pdf response has wrong encoding - xhtml2pdf

I'm working on an invoice PDF generator on my Django website. I use xhtml2pdf. It seems to be working but encodings is not correct. There are wrong signs/characters when I use diacritics. This is a view: def render_to_pdf(template_src,…
Milano
  • 18,048
  • 37
  • 153
  • 353
7
votes
1 answer

xhtml2pdf Pisa css broken none functional

I am trying to generate a PDF using html+css using xhtml2pdf.pisa using Django. However, I'm running into all sorts of weird issues with the CSS. Below is my code: from django.template.loader import render_to_string import cStringIO as…
pinghsien422
  • 19,836
  • 1
  • 20
  • 22
7
votes
3 answers

CSS parsing error when creating pdf with xhtml2pdf pisa.CreatePDF()

I am following the xhtml2pdf guides. I have used one of the sample html files and saved as test.html: