reportlab

Using Reportlab Canvas- How to create an Option to print the pdf generated from the browser itself?

纵饮孤独 提交于 2019-12-04 17:41:04
Here is the code which generates pdf for me using Reportlab. Now, it just shows the pdf in the browser, and after including 'attachment' in the resonse.header ['Content-Disposition'], it downloads the pdf. But what i want is the rint option which comes you in the browser, which even allows you to choose your printer. is it possible ? data = "raghav" p = canvas.Canvas(self.response.out) p.drawString(50, 700, data) p.showPage() self.response.headers['Content-Type'] = 'application/pdf' self.response.headers['Content-Disposition'] = 'attachment;filename=testpdf.pdf' p.save() according to http:/

Can I inherit from a standard report in OpenERP?

巧了我就是萌 提交于 2019-12-04 14:55:25
I want to make changes to the purchase order report in OpenERP 6.1. Do I have to go in and make changes to the purchase module, or can I create a new module that will inherit the standard report and override some details. Don Kirkby You can't exactly inherit another report and just override some details, but you can replace a standard report and make all existing links to it launch your new report instead. Our zaber_purchase module contains some changes to the purchase order report that our users wanted. Here's the purchase_report.xml file that replaces the standard report with ours. <?xml

Adding Graph to Reportlab PDF

谁说我不能喝 提交于 2019-12-04 12:14:24
I have seen many reportlab graphing examples. Generating the graph is not the problem, I can't seem to figure out how to display the graph on the pdf. Here is the code: buffer = StringIO() p = canvas.Canvas(buffer, pagesize = letter) ##### Beginning of code in question d = Drawing(200, 100) pc = Pie() pc.x = 65 pc.y = 15 pc.width = 70 pc.height = 70 pc.data = [10,20,30,40,50,60] pc.labels = ['a','b','c','d','e','f'] pc.slices.strokeWidth=0.5 pc.slices[3].popout = 10 pc.slices[3].strokeWidth = 2 pc.slices[3].strokeDashArray = [2,2] pc.slices[3].labelRadius = 1.75 pc.slices[3].fontColor = colors

reportlab: add background image by using platypus

别说谁变了你拦得住时间么 提交于 2019-12-04 12:05:51
this is a bit related to this post I am trying to place an image on the background, and I want to be able to write text over it. using canvas.drawImage helps, but that's too low level approach for me. My program uses platypus, but canvas.drawImage is part of different library. I've been able to insert images with platypus.Image , but couldn't figure out how to make it as background. Any advice would be great, Thanks D When you create a page template in Platypus you have the ability to pass a function via the named argument onPage . In that function you can place all your basic page formatting

Add page break to Reportlab Canvas object

我只是一个虾纸丫 提交于 2019-12-04 10:48:34
问题 I need to generate a 2 pages pdf report. Pages are completely independent. tried using: mycanvas.drawString(x, y, "Printing on Page 1") mycanvas._pageNumer = 2 mycanvas.drawString(x, y, "Printing on Page 2") and: mycanvas.drawString(x, y, "Printing on Page 1") P = PageBreak() P.drawOn(mycanvas, 0, 1000) mycanvas.drawString(x, y, "Printing on Page 2") But everything is printed on the same page. How should I add a page break to this Canvas instance ? 回答1: Just call mycanvas.showPage() once page

How to change text/font color in reportlab.pdfgen

南笙酒味 提交于 2019-12-04 08:34:12
问题 I want to use a different color of text in my auto-generated PDF. According to the reportlab docs all I need to do is: self.canvas.setFillColorRGB(255,0,0) self.canvas.drawCentredString(...) But that doesn't do anything. The text is black no matter what. 回答1: If you copy and paste the code in User Guide Section 2. You'll get a fancy coloured rectangle with a coloured Text within it. Probably the approach is not that clear in the user guide, I'd spent some time playing with it and I finally

Troubleshoot reportlab heisenbug

早过忘川 提交于 2019-12-04 07:45:25
Using Django 1.4 / Python 2.7 / reportlab (open source version) to generate pdf. Things have worked really great up until now. Previously pdf generation (as in http requested returned/downloaded generated pdf file) was on Django 1.3 and not open for public. Have upgraded and made feature free on many pages and now starting to have problems. I get 'random' problems (as in I see there are exceptions once in a while in logs) but I have never been able to reproduce problems myself (things works most of the time). What I get is the following type of errors that always happens in pairs Exception

Django ReportLab: using Drawing object to create PDF and return via Httpresponse

邮差的信 提交于 2019-12-04 06:55:51
In ReportLab, Drawing object can be written into different renderers, e.g d = shapes.Drawing(400, 400) renderPDF.drawToFile(d, 'test.pdf') and in Django, Canvas object can be sent via httpresponse, e.g.: response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'filename=test.pdf' c = canvas.Canvas(response) in my case, my problem is that I have a reportLab script using Drawing object which saves to local file system. I now put it in Django views, and wondering whether there is a way to not save to local file system but instead sent back to client. I hope I describe

How to create a PDF document with differing page sizes in reportlab, python

两盒软妹~` 提交于 2019-12-04 01:46:18
Is it possible to create a PDF document with differing page sizes in reportlab? I would like to create a document where the first page has a different size then the other pages. Can anyone help? Yes, this should be possible, since PDF supports this, it's just a question of how to make it happen in ReportLab. I've never done this, but the following should work: c = reportlab.pdfgen.canvas.Canvas("test.pdf") # draw some stuff on c c.showPage() c.setPageSize((700, 500)) #some page size, given as a tuple in points # draw some more stuff on c c.showPage() c.save() And your document should now have

django: serve dynamic (reportlab) png to template

≯℡__Kan透↙ 提交于 2019-12-04 01:36:29
问题 I've spent the day on this issue with no success so help would be appreciated. I generate a graph using reportlab and successfully render it to the browser using this tutorial: d = MyBarChartDrawing() #extract the request params of interest. #I suggest having a default for everything. if 'height' in request: d.height = int(request['height']) if 'width' in request: d.width = int(request['width']) if 'numbers' in request: strNumbers = request['numbers'] numbers = map(int, strNumbers.split(','))