xhtml2pdf

Converting a html template containing highcharts to pdf

荒凉一梦 提交于 2020-08-10 19:17:20
问题 I have a html template with highcharts in it.I have to mail these reports after converting to pdf.I tried to use xhtml2pdf but it just loads everything but the charts.Here is my code (view.py) from io import BytesIO from xhtml2pdf import pisa from schedule.settings import EMAIL_HOST_USER from django.core.mail import EmailMessage def sender1(request): userid = request.user.email template = get_template('html.html') context = { 'pagesize': 'A3', } html = template.render(context) result =

Django - pdf response has wrong encoding - xhtml2pdf

为君一笑 提交于 2020-07-08 11:54:12
问题 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, context_dict): template = get_template("pdf/pdf.html") 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 HttpResponse(result

How to change a queryset for xhtml2pdf via ajax

陌路散爱 提交于 2020-04-17 21:30:46
问题 im trying to build a function where by the user is able to select the items he wishes to render to pdf. In order to do this, i first did some code to store the PK of the items the user selected. (javascript) var arr = [] function selector(clicked_id){ var a = clicked_id if (arr.includes(a) === false){ arr.push(a) document.getElementById(a).classList.add('bg-light'); } else { const index = arr.indexOf(a) arr.splice(index, 1) document.getElementById(a).classList.remove('bg-light') } console.log

number cannot be wrapped in flyingsaucer and itext

邮差的信 提交于 2019-12-25 07:29:16
问题 environment is : flyingsaucer r8 and itext 2.0.8 I'm going to create pdf file with flyingsaucer and itext, I added table-layout:fixed;word-wrap:break-word; to wrap the cell content. However, the generated pdf file looks like next : from the above diagram, we can see that over long English sentence of column 'Description' can be wrapped correctly, but the over long number in 'Account Code' and 'Description' cannot be wrapped. I also tried "word-break: break-all;", but it still doesn't work. my

what is the uni code encoding error in the code below [duplicate]

痴心易碎 提交于 2019-12-25 03:44:48
问题 This question already has answers here : UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' - -when using urlib.request python3 (2 answers) Closed 5 months ago . I'm getting the following unicode encoding error . When I'm running the program presented below, I'm getting a unicode encoding-related error import bs4 import requests from xhtml2pdf import pisa # import python module from xhtml2pdf.config.httpconfig import httpConfig res = requests.get("https://www.insightsonindia.com

'django.template.context_processors.request' issue with django-tables2 and django-admin-tools

你离开我真会死。 提交于 2019-12-12 17:17:23
问题 I'm having an issue when trying to render a PDF through xhtml2pdf in Django(1.10.4) when using django-admin-tools(0.8.0) & django-tables2(1.5) together. I've done enough reading to understand the basis of what's going on but have not idea how to fix it. I think it's got something to do with the django-admin-tools custom loaders. Link to the exception I'm getting from django-tables. This SO question led me to asking a question. The gist of what I'm trying to do is create a custom Admin 'action