xhtml2pdf

trouble in converting unicode template to pdf using xhtml2pdf

懵懂的女人 提交于 2019-12-12 12:41:10
问题 I have unicode used in my html page, which is displaying correctly in the html page. But while converting it into html using xhtml2pdf, it generating black, solid square boxes in the unicodes. Is there some setting for unicode other than UTF-8 setting. I dont think its unicode problem. # convert HTML to PDF pisaStatus = pisa.CreatePDF( StringIO(sourceHtml.encode('utf-8')), dest=resultFile) Complete py code: # -*- coding: utf-8 -*- from xhtml2pdf import pisa from StringIO import StringIO

JsPdf page break not working

天涯浪子 提交于 2019-12-11 15:15:35
问题 I have this very simple code that works with jspdf and html2pdf but for some reason jspdf is not breaking the elements into new pages. Any help would be appreciated <!DOCTYPE html> <html> <head> <title>Html2Pdf</title> <link rel="stylesheet" type="text/css" href="examples.css"> <style> table { margin-bottom: 1em; } table td { padding: 3px; } .table1 { border: 1px solid red; } .table2,.table2 td { border: 1px solid silver; border-collapse: collapse; } .table2 td:first-child { background-color:

How to set the width of the page?

…衆ロ難τιáo~ 提交于 2019-12-11 05:11:27
问题 I have been trying to increase the width of pdf but nothing seems to work: <style type="text/css"> @page { size: a4 landscape; width: 27cm; /* not working */ @frame content { top: 2cm; width: 27cm; /* not working */ margin-left: 1.5cm; /* changing these values work!! */ margin-bottom: 2cm; /* changing these values work!! */ } } </style> No matter what I try, the content width doesn't seem to increase. All my <div> , <tables> are at 100%, and reducing the margin increases the size of the table

Django / xhtml2pdf - object has no attribute 'encode'

狂风中的少年 提交于 2019-12-10 11:35:00
问题 I'm having a hard time producing pdf's in Django. As per my previous question I'm running into the same error. When I run the following code I get 'list' object has no attribute 'encode' , a pdf is saved in the media folder but it is a plain text file. I think the object that is being referred to is the sections queryset. @login_required def generate_pdf(request, slug): # Prepare context document = get_object_or_404(Document, slug=slug) sections = \ get_list_or_404(Section.objects.filter

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

旧街凉风 提交于 2019-12-09 05:39:34
问题 The below code gives error: Traceback (most recent call last): File "pdf.py", line 14, in <module> create_pdf(render_template('templates.htm')) File "/usr/local/lib/python2.7/dist-packages/flask/templating.py", line 123, in render_template ctx.app.update_template_context(context) AttributeError: 'NoneType' object has no attribute 'app' Code: from xhtml2pdf import pisa from StringIO import StringIO from flask import render_template,Flask app=Flask(__name__) app.debug=True @app.route("/") def

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 =

Django / xhtml2pdf - object has no attribute 'encode'

こ雲淡風輕ζ 提交于 2019-12-06 06:46:51
I'm having a hard time producing pdf's in Django. As per my previous question I'm running into the same error. When I run the following code I get 'list' object has no attribute 'encode' , a pdf is saved in the media folder but it is a plain text file. I think the object that is being referred to is the sections queryset. @login_required def generate_pdf(request, slug): # Prepare context document = get_object_or_404(Document, slug=slug) sections = \ get_list_or_404(Section.objects.filter (associated_document__startswith=document.slug)) data = {'document': document, 'sections': sections} #

python - jinja2 - putting all html from python into one PDF (rather than multiple)

喜夏-厌秋 提交于 2019-12-05 02:58:08
问题 I was given some great code by 'tuomastik' on this site, and have tweaked it slightly to work for me. However, I have spent several hours trying to edit it so it prints to one PDF rather than multiple (one PDF, but each report starting on a fresh page), but my HTML isn't as good as I want to be, and I am getting stuck. The code is: HTML <html> <head> <style type="text/css"> html, body { width: 500px; font-size: 12px; background: #fff; padding: 0px; } #my-custom-table { width: 500px; border: 0

python - jinja2 - putting all html from python into one PDF (rather than multiple)

亡梦爱人 提交于 2019-12-03 17:14:31
I was given some great code by 'tuomastik' on this site, and have tweaked it slightly to work for me. However, I have spent several hours trying to edit it so it prints to one PDF rather than multiple (one PDF, but each report starting on a fresh page), but my HTML isn't as good as I want to be, and I am getting stuck. The code is: HTML <html> <head> <style type="text/css"> html, body { width: 500px; font-size: 12px; background: #fff; padding: 0px; } #my-custom-table { width: 500px; border: 0; margin-top: 20px; } #my-custom-table td { padding: 5px 0px 1px 5px; text-align: left; } </style> <

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