reportlab

Splitting ReportLab table across PDF page (side by side)?

China☆狼群 提交于 2019-12-08 07:11:03
问题 The code below creates a nice test table with 99 rows of data and a header that gets repeated at each page break. The table is quite narrow so I am trying to figure out how to make it split so that it has rows 1-37 on the left hand side of the first page, rows 38-74 on the right hand side of the first page, and rows 75-99 on the left hand side of the second page. I've called this "splitting a table across a page" but there may be a better name for what I am trying to do so I hope I have

Relative File Linking in PDF (Reportlab)

假如想象 提交于 2019-12-08 05:47:14
问题 Is it possible to link to a relative external document that isn't a PDF file from a PDF document? I'm specifically thinking something like an excel spreadsheet. In ReportLab I can add something like Elements.append(Paragraph("<a href=\"pdf://linkedfile.pdf\">File</a>",style)) and it will successfully link to and open linkedfile.pdf in the same folder as my generated PDF, however the documentation doesn't mention any other file types other than pdf and obviously xls:// doesn't work. Does

How to write table structure data in PDF file in python?

假装没事ソ 提交于 2019-12-08 03:36:29
问题 +----+-----------------------------+ | id | name | +====+=============================+ | 47 | Some textjogjwojgopwgpowmok | +----+-----------------------------+ | 47 | Some textjogjwojgopwgpowmokg| +----+-----------------------------+ | 47 | Some textjogjwojgopwgpowmokg| +----+-----------------------------+ | 47 | Some textjogjwojgopwgpowmokg| +----+-----------------------------+ | 47 | Some textjogjwojgopwgpowmokg| +----+-----------------------------+ I want to write the above table in PDF

Dynamically generated PDF files working in most readers except Adobe Reader

馋奶兔 提交于 2019-12-08 03:31:00
问题 I'm trying to dynamically generate PDFs from user input, where I basically print the user input and overlay it on an existing PDF that I did not create. It works, with one major exception. Adobe Reader doesn't read it properly, on Windows or on Linux. QuickOffice on my phone doesn't read it either. So I thought I'd trace the path of me creating the files - 1 - Original PDF of background PDF 1.2 made with Adobe Distiller with the LZW encoding. I didn't make this. 2 - PDF of background PDF 1.4

How to know on what page number flowable was placed during rendering a pdf with reportlab

北慕城南 提交于 2019-12-08 03:00:02
问题 How to determine on what page(need a page number) will be each flowable after rendering to pdf. I was thinking to add a custom id attribute to flowable, so i will know what flowable is it. But how can i determine on what page it will be placed? What is the best way to achieve this? 回答1: At what point do you need this information? It becomes available as the document is constructed, so you can get it after rendering by overriding methods such as afterPage , afterDrawPage , and afterFlowable .

Reportlab - Add two Paragraphs into one table cell

橙三吉。 提交于 2019-12-08 01:30:43
问题 I have a table which is build up like the following: styleN = styles["Normal"] data = [] table_row = ['ID', 'Some Information'] data.append(table_row) table_row = [] table_row.append(Paragraph(object.ID, styleN)) table_row.append(Paragraph(object.some_information1, styleN)) data.append(table_row) t = Table(data, (6*cm,6*cm,2*cm,2*cm,2*cm), row_heights, style=ts) Now I want to achieve that I can add into the second cell a second paragraph containing object.some_information2. Some more or less

Porting to Python3: PyPDF2 mergePage() gives TypeError

↘锁芯ラ 提交于 2019-12-07 16:29:29
问题 I'm using Python 3.4.2 and PyPDF2 1.24 (also using reportlab 3.1.44 in case that helps) on windows 7. I recently upgraded from Python 2.7 to 3.4, and am in the process of porting my code. This code is used to create a blank pdf page with links embedded in it (using reportlab) and merge it (using PyPDF2) with an existing pdf page. I had an issue with reportlab in that saving the canvas used StringIO which needed to be changed to BytesIO, but after doing that I ran into this error: Traceback

2 Axes Reportlab Graph

情到浓时终转凉″ 提交于 2019-12-07 08:14:19
问题 I have managed to create a 2 axes graph in ReportLab, by overlapping a barchart and linepot. Here is the code for anyone interested in something similar: from reportlab.graphics.shapes import Drawing,colors from reportlab.graphics.widgets.markers import makeMarker from reportlab.graphics.charts.barcharts import VerticalBarChart from reportlab.graphics.charts.lineplots import LinePlot drawing = Drawing(400, 200) data = [(13, 5, 20, 22, 37, 45, 19, 4) ] noOfBars=len(data[0]) bc =

What is the simplest way to add a hyperlink to a canvas element in ReportLab?

做~自己de王妃 提交于 2019-12-07 05:25:30
问题 I am using ReportLab to make a pdf using Python. I want to add a shape to the canvas, and have that shape act as a hyperlink. What is the simplest way to make the rectangle in the following example link to google.com? from reportlab.pdfgen import canvas from reportlab.lib.units import inch c = canvas.Canvas("hello.pdf") # move the origin up and to the left, draw square c.translate(inch,9*inch) # How do I make this rectangle link to google.com? c.rect(inch,inch,1*inch,1*inch, fill=1) c

Pandas DataFrames in reportlab

吃可爱长大的小学妹 提交于 2019-12-07 04:57:05
问题 I have a DataFrame, and want to output it to a pdf. I'm currently trying to use ReportLab for this, but it won't seem to work. I get an error here: mytable = Table(make_pivot_table(data, pivot_cols, column_order, 'criterion')) make_pivot_table just returns a pivot table using pandas pivot_table function. The error I get is ValueError: <Table@0x13D7D0F8 unknown rows x unknown cols>... invalid data type My questions are: Is there any way to make reportlab work with DataFrames? If not, what