pisa

How to send pdf as an email attachment in Django

流过昼夜 提交于 2019-12-07 04:07:26
问题 Hi I am using the follwoing 2 functions to create and send a pdf via mail on the fly. What Am I doing wrong. (The export pdf function works properly when showing it in the browser.) The error I am getting is "TypeError: 'ContentFile' object does not support indexing" . What I am doing wrong? Almost all of this code has been taken from some blogs, so I dont know how it exactly works. But if you dont understand some things please comment. I will reply. if request.method=="POST": form =

trouble using xhtml2pdf with unicode

[亡魂溺海] 提交于 2019-12-06 14:24:26
问题 I've been trying to convert Hebrew html files without success; the Hebrew characters show up in the output PDF as black rectangles regardless of any encoding I tried. I tried some unicode test files included in the pisa distribution: pisa-3.0.33\test\test-unicode-all.html and \test-bidirectional-text.html . I ran xhtml2pdf from the command line both with and without --encoding utf-8 . Same result: none of the non-Latin characters made it through. Is this a fonts problem*? If the unicode test

Output image to pdf with xhtml2pdf

与世无争的帅哥 提交于 2019-12-06 12:04:30
问题 I followed this post : django - pisa : adding images to PDF output and using fetch_resources. The PDF file can be generated normally except the image is missing. This is my code: def fetch_resources(uri, rel): path = os.path.join(settings.MEDIA_ROOT, uri.replace(settings.MEDIA_URL, "")) return path def render_to_pdf(template_src, context_dict, filename): template = get_template(template_src) context = Context(context_dict) html = template.render(context) result = StringIO.StringIO() pdf =

How to send pdf as an email attachment in Django

喜夏-厌秋 提交于 2019-12-05 09:39:45
Hi I am using the follwoing 2 functions to create and send a pdf via mail on the fly. What Am I doing wrong. (The export pdf function works properly when showing it in the browser.) The error I am getting is "TypeError: 'ContentFile' object does not support indexing" . What I am doing wrong? Almost all of this code has been taken from some blogs, so I dont know how it exactly works. But if you dont understand some things please comment. I will reply. if request.method=="POST": form = ReportSendMailForm(request.POST) if form.is_valid(): email = form.cleaned_data['mail'] message = form.cleaned

trouble using xhtml2pdf with unicode

蹲街弑〆低调 提交于 2019-12-04 19:34:27
I've been trying to convert Hebrew html files without success; the Hebrew characters show up in the output PDF as black rectangles regardless of any encoding I tried. I tried some unicode test files included in the pisa distribution: pisa-3.0.33\test\test-unicode-all.html and \test-bidirectional-text.html . I ran xhtml2pdf from the command line both with and without --encoding utf-8 . Same result: none of the non-Latin characters made it through. Is this a fonts problem*? If the unicode test file works for you, was there anything you did to set it up? *FWIW, at least some of these languages,

Is there a way to generate pdf containing non-ascii symbols with pisa from django template?

六月ゝ 毕业季﹏ 提交于 2019-12-04 08:58:58
问题 I'm trying to generate a pdf from template using this snippet: def write_pdf(template_src, context_dict): template = get_template(template_src) context = Context(context_dict) html = template.render(context) result = StringIO.StringIO() pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")), result) if not pdf.err: return http.HttpResponse(result.getvalue(), mimetype='application/pdf') except Exception('PDF error') All non-latin symbols are not showing correctly, the template and

xhtml2pdf doesn't embed Helvetica

倾然丶 夕夏残阳落幕 提交于 2019-12-02 18:09:47
问题 I'm creating a PDF with xhtml2pdf using Django. I'm sending that PDF to print, but then they say that some Fonts are not embed. I have a Helvetica font, but I didn't use Helvetica in the PDFs. Here you have a Screen Shot of the properties of the PDF As you see, Guilles'ComicFont and TF2Secondary are correclty embbeded, but not with Helvetica. Here you have my view that generates the PDF: def generate_pdf(request, book, order): try: book = Book.objects.get(pk=int(book)) order = Order.objects

xhtml2pdf doesn't embed Helvetica

你。 提交于 2019-12-02 08:22:31
I'm creating a PDF with xhtml2pdf using Django. I'm sending that PDF to print, but then they say that some Fonts are not embed. I have a Helvetica font, but I didn't use Helvetica in the PDFs. Here you have a Screen Shot of the properties of the PDF As you see, Guilles'ComicFont and TF2Secondary are correclty embbeded, but not with Helvetica. Here you have my view that generates the PDF: def generate_pdf(request, book, order): try: book = Book.objects.get(pk=int(book)) order = Order.objects.get(identificador=order, cuento=book) except ObjectDoesNotExist: raise Http404 data = {} data = ast

html to .doc converter in Python?

与世无争的帅哥 提交于 2019-11-27 14:48:20
I am using pisa, which is an HTML to PDF conversion library for Python. Does there exist the same thing for a Word document: an HTML to .doc conversion library for Python? You could use win32com from the pywin32 python extensions for windows, to let MS Word convert it for you. A simple example: import win32com.client word = win32com.client.Dispatch('Word.Application') doc = word.Documents.Add('example.html') doc.SaveAs('example.doc', FileFormat=0) doc.Close() word.Quit() Though I am not aware of a direct module that can allow you to convert this, however: You can convert HTML to plain text

django - pisa : adding images to PDF output

混江龙づ霸主 提交于 2019-11-26 22:06:01
I'm using a standard example from the web ( http://www.20seven.org/journal/2008/11/pdf-generation-with-pisa-in-django.html ) to convert a django view / template into a PDF. Is there an "easy" way to include images (either from a url or a reference on the server) in the template so they will show on the PDF? I got the images working. the code is as follows: from django.http import HttpResponse from django.template.loader import render_to_string from django.template import RequestContext from django.conf import settings import ho.pisa as pisa import cStringIO as StringIO import cgi import os def