reportlab

graphing sqlite3 data with reportlab

折月煮酒 提交于 2019-12-12 01:39:18
问题 trying to lineplot simple temperature data from a sqlite3 database. New to python, not sure what I'm doing wrong. my data from sql looks like: [(70.8,), (70.8,), (70.9,), (71.0,), (71.0,), (71.2,), (71.2,), (71.2,), (71.4,), (71.7,), (71.7,), (72.0,), (72.0,), (72.0,), (72.2,), (72.2,), (71.9,), (72.0,), (72.0,), (72.2,), (72.2,), (72.2,), (72.2,), (71.7,), (71.9,), (71.9,), (72.0,), (72.0,), (72.3,), (72.0,), (72.0,), (72.2,), (72.2,), (72.2,), (72.3,), (72.2,), (72.2,), (72.3,), (72.3,),

ReportLab in Django

微笑、不失礼 提交于 2019-12-11 20:33:33
问题 I'm making a bar graph using ReportLab in Django. I'm able to get the pdf generated, but it is saved in my root directory. Instead I want that the PDF should opened in the browser itself. How can I do it? from reportlab.graphics.shapes import Drawing from reportlab.graphics.charts.barcharts import VerticalBarChart from reportlab.graphics import renderPDF from django.http import HttpResponse def generate_report(request): drawing = Drawing(400, 200) data = [ (13, 5, 20, 22, 37, 45, 19, 4) ] bc

Reportlab , How to change page orientation?

◇◆丶佛笑我妖孽 提交于 2019-12-11 20:12:23
问题 I am creating pdf file that containing many pages. I want first page to be portrait and rest of the pages will be landscape. I tried, story.append(NextPageTemplate('landscape')) refererence But I got, ValueError: can't find template('landscape') handle_nextPageTemplate args=('landscape',) 回答1: I just figured out. doc = BaseDocTemplate("mypdf.pdf", pagesize=A4, rightMargin=25, leftMargin=25, topMargin=25, bottomMargin=25) portrait_frame = Frame(doc.leftMargin, doc.bottomMargin, doc.width, doc

How to incorporate Reportlab with Django Class Based View?

走远了吗. 提交于 2019-12-11 18:45:39
问题 I am trying to convert my HTML to a PDF. I watched this tutorial, https://www.codingforentrepreneurs.com/blog/html-template-to-pdf-in-django/ and I was able to successfully get the tutorial to work with hardcoded values. The problem is...I can't figure out how to dynamically incorporate my model and it's attributes into this example. Here are the steps I followed... First I installed reportlab into my environment with the following version... pip install --pre xhtml2pdf This worked... Then I

instantiate python class from class available as string , only in memory!

南笙酒味 提交于 2019-12-11 18:31:04
问题 I'm using Reportlab to create PDFs. I'm creating two PDFs which I want to merge after I created them. Reportlab provides a way to save a pycanvas (source) (which is basically my pdf file in memory) as a python file, and calling the method doIt(filename) on that python file, will recreate the pdf file. This is great, since you can combine two PDFs on source code basis and create one merge pdf. This is done like this: from reportlab.pdfgen import canvas, pycanvas #create your canvas p =

Reportlab: Align, vAlign Table to the 'BOTTOM' of a Frame

一笑奈何 提交于 2019-12-11 17:53:35
问题 I have problem to align a Table object to the bottom of a Frame, hAlign 'RIGHT' and 'LEFT' works, but it seem to be stuck in 'TOP', how do I vAlign the Table down to 'MIDDLE' or the 'BOTTOM' of the Frame? Below is a complete and run-able example. Please note it is table within the Frame that should be on the bottom, meaning the table is in the bottom right corner (now, below table is on TOP of the frame). from reportlab.lib.pagesizes import letter from reportlab.lib import colors from

Issues with pyinstaller and reportlab

£可爱£侵袭症+ 提交于 2019-12-11 12:47:42
问题 Alright so I have a python project that I want to compile, so I decided to use pyinstaller (first time compiling python). Now it compiled fine but when I run the exe it returns -1. So after a bit of messing around I figured out that it was related to reportlab.platypus. So my first instinct was to check to see if using hooks changed anything, so I tried adding the reportlab.pdfbase._fontdata and reportlab.lib.utils hooks (these were the only hook files I could find related to reportlab).

Reportlab Canvas Image Not Showing

丶灬走出姿态 提交于 2019-12-11 09:07:38
问题 Background I am writing some code to set up a shared document "template" [ common header and footer ] in ReportLab using a SimpleDocTemplate ( reportlab.platypus.SimpleDocTemplate ). The code snippet below is a function that is to be passed into the SimpleDocTemplate build(...) method as the value of either the onFirstPage or onLaterPages parameter. def setup_header_and_footer(canvas, doc): """ ...edited out... """ canvas.line(0 * mm, 174 * mm, 297 * mm, 174 * mm) logo_filename = settings

Reportlab does not reset sequences when creating multiple documents with table of contents

最后都变了- 提交于 2019-12-11 06:08:12
问题 I am using a template function that creates multiple PDF documents in one program execution using reportlab. These documents are identical by structure and have identical headings. They only differ in content below the headings. All of these documents contain a table of contents element. I am using sequence tags ( <seq/> etc.) to create numbered headings e. g. 1. Top1 1.1 Sub1 2. Top2 2.1 Sub1 2.2 Sub2 This works well for one single document but as soon as I create a second one right after

How to draw image from raw bytes using ReportLab?

北城余情 提交于 2019-12-11 05:16:27
问题 All the examples I encounter in the internet is loading the image from url (either locally or in the web). What I want is to draw the image directly to the pdf from raw bytes. UPDATE: @georgexsh Here is my code based on my understanding of your comment below: def PDF_view(request): response = HttpResponse(content_type='application/pdf') ... page = canvas.Canvas(response, pagesize=A4) page.setTitle("Sample PDF") image = StringIO(raw_image_bytes) # raw_image_bytes is from external source image