FAQ Database Discussion Community


Two different pages with reportlab SimpleDocTemplate and Django

python,django,reportlab
I'm using django and generating reports following this example, I need to generate a last page but without headers or footers and different content. I'm trying to do this: def print_example(self): buffer = self.buffer doc = SimpleDocTemplate(buffer, rightMargin=72, leftMargin=72, topMargin=72, bottomMargin=72, pagesize=self.pagesize) elements = [] elements.append(Paragraph('Content for all pages'), my_custom_style)...

Insert multiple images in a single PDF according to image.coordinates - Python

python,image,pdf,reportlab
I have a image path's and corresponding coordinates as a dict. Ex: {'coords': [u'530,88,592,99'], 'filepath': 1.jpg}, {'coords': [u'7,12,152,85'], 'filepath': 2.jpg}, {'coords': [u'448,12,594,86'], 'filepath': 3.jpg} I would like to generate a single PDF with all the images as per the relative-coordinates of the images. I guess, it might be possible with...

Provide tab title with reportlab generated pdf

python,django,pdf-generation,httpresponse,reportlab
This question is really simple, but I can't find any data on it. When I generate a pdf with reportlab, passing the httpresponse as a file, browsers that are configured to show files display the pdf correctly. However, the title of the tab remains "(Anonymous) 127.0.0.1/whatnot", which is kinda ugly...

Can't setFont(Times-Roman) missing the T1 files?

python,openerp,reportlab,odoo
I have the error : Can't find .pfb for face 'Times-Roman' Error: reportlab.graphics.renderPM.RenderPMError: Can't setFont(Times-Roman) missing the T1 files? I think the Times-Roman fonts is not getting. Can anyone have a solution for this one. Thanks....

User downloadable PDFs in Google App Engine returning corrupted PDFs

python,google-app-engine,pdf,reportlab
I've created a python script that generates a PDF from supplied user data using reportlab. The PDFs download fine and everything works when I run the script from the command line. However when I try to pass the file to Google App Engine like this: ... outputstream = StringIO.StringIO() PDF...

Python Reportlab multiple lines

python,pdf,subprocess,reportlab
I am trying to write my disk status to a pdf. The problem is it's failing in writing multiple lines: the text for each letter goes vertically. import subprocess from reportlab.pdfgen import canvas p = subprocess.Popen('df -h', stdout=subprocess.PIPE, shell=True) (disk, err) = p.communicate() print disk def hello(disk): height= 700 c...

How to extract elements from a list of tuples in python for a ReportLab table?

python,reportlab
I have a problem with creating a reportlab table containing elements from a list of tuples. Having the input: meta= [('#Instances (Test)', '250'), ('#Instances (Train)', '250')] I intuitively thought of writing it that way: for key, value in meta: data = [['Solver', '%s'%(solver_name)], ['%s'%(key), '%s'%(value)], ['%s'%(key), '%s'%(value)]] meta_data = Table(data,...

Generate pdf with reportlab

python,django,pdf,reportlab
In django project trying to create a pdf using python-reportlab from reportlab.pdfgen import canvas response = HttpResponse(content_type='application/pdf') response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"' p = canvas.Canvas(response) p.drawString(10, 800, "Name") p.drawString(10, 900, "Address") p.drawString(10, 1000, "School") p.showPage() p.save() On output pdf It only shows the Name, what happened to other two strings ?...

Save reportlab pdf file without show it

python,pdf,reportlab
I am using reportab to generate a pdf file. The last sentences of my script are as follows: doc.build(story) os.system('xxxx.pdf') # show the pdf file. Then leave the script and save the created pdf file where I like. But, I want to know how can I save the file without...

How can I display data in table in columns, not row?

python,reportlab
I'm using Reportlab for pdf generate. How can I display data in table in columns, not row? Current output: Expected output: So data should be displayed in columns, not row. Here my code: # -*- coding: utf-8 -*- from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import A4, landscape from reportlab.platypus.tables import...

how to know the end of a frame to create a new one reportlab

python,pdf,frame,reportlab,paragraph
I built a pdf using reportlab, to have more controle one the page (colors- padding- return to line...) I created a frame. the issue is that, my text is coming from a database and it need more than one page. I want to know how to tell that its the...

Python pip install reportlab error

python,windows,install,reportlab
I am trying to install reportlab for python. I have Windows 7, Python 2.7 and Visual Studio 2013 and I am using the command line "pip install reportlab" but it is not working. I have the pip log file data that was generated - what is the best way to...

A simple method for rotate images in reportlab

python,reportlab
How can we rotate easily an image using reportlab ? I looked for and I do not found an easy method. The only way found comes from http://dods.ipsl.jussieu.fr/orchidee/SANORCHIDEE/TEMP/TEMP_LOCAL/cdat_portable/lib_new_wrong_gcc/python2.4/site-packages/reportlab/test/test_graphics_images.py using for example: >>> from reportlab.graphics.shapes import Image, Drawing >>> from reportlab.platypus import SimpleDocTemplate >>> from reportlab.lib.pagesizes import A4, portrait >>> from...

When I want to use the python reportlab to save a pdf ,I get the trouble when using path with nonASCII characters?

python,pdf,pdf-generation,reportlab,python-unicode
i write some simply function to produce pdf from reportlab ,but when the path is nonASCII(for example chinese) there comes problems UnicodeDecodeError: 'utf8' codec can't decode byte 0xd0 in position 3: invalid continuation byte. and when the path is all ASCII everything is fine. my code is very simply ,just...

Reportlab Unordered List not showing bullets

python,tinymce,pdf-generation,reportlab,rml
Whenever users input unordered lists using TinyMCE and it will look like this under source code <ul> <li>item 1</li> <li>item 2</li> <li>item 3</li></ul> When it renders to PDF using reportlab, it shows up without bullets all on the same line like this: item 1 item 2 item 3 Below is...

reportlab TypeError: drawImage() takes at least 4 arguments (5 given)

python,reportlab
I'm trying to create a report using reportlab in python. Here are the relevant lines before the problem: from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import letter from reportlab.lib.pagesizes import landscape c = canvas.Canvas(pdf_file_name, pagesize=landscape(letter)) here is line 53 from my python script: c.drawImage(350, 50, width=None,height=None) I get the following error:...