Profile cover photo
Profile photo
Markus Weller
102 followers
102 followers
About
Posts

Post has attachment
Yes yes yes ... someone give this guy a cookie. That's totally how I felt about "The slow regard of silent things"
Add a comment...

Post has attachment
"[...] being invisible online is as much of a red flag as a bad reputation."

This is so true ... people should stop telling everyone to stop posting a lot to the internet.

Having more content and followers will make bad and even embarrassing content disappear faster and less visible.
Add a comment...

Post has shared content
Let me tell you a TCP joke...
Photo
Add a comment...

Post has attachment

Post has shared content
A Chrome extension for showing your GitHub repository in a tree format http://programming.com/social/posts/3894713509002348533

via +Programming.com
Photo
Add a comment...

Post has attachment

Post has attachment
Generate PDFs with Python using Reportlab

While a plain Python installation can't create PDFs it surely is possible, but you have to download a plugin like Reportlab in order to do this.
Fedora has Reportlab in its Repositories so "yum install python-reportlab" will do the job, on Debian Systems "apt-get install python-reportlab" does the same. Python 3 users probably have to be patient because there is still no version available.
Other version like Windows and the Sourcecode are available here:
http://www.reportlab.com/software/opensource/rl-toolkit/download/

Reportlab has a documentation but the documentation is incomplete and more a 'Getting started' Guide. Butthere is a Code Snippet section on the website which can be very helpful.

https://www.reportlab.com/docs/reportlab-userguide.pdf
http://www.reportlab.com/snippets/

The most basic part of Reportlab is the canvas object in the pdfgen package. It is like canvas objects in other programming languages and yet more similar to PostScript. For instance the anchor of the canvas is the bottom left corner.

Here is a very basic canvas sample:

from reportlab.pdfgen import canvas

canv = canvas.Canvas("hello1.pdf")
canv.drawString(100,100,"Hello World")
canv.save()

The next sample shows how to use other units than Pixels and Page sizes:

from reportlab.pdfgen import canvas
from reportlab.lib.units import cm, inch

canv = canvas.Canvas('hello2.pdf')
canv.setPageSize((20*cm, 30*cm))
canv.drawString(2*inch,2*inch,"Hello World")
canv.save()

In order to add images you will have to do it like this:

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

canv = canvas.Canvas('hello3.pdf', pagesize=letter)
width, height = letter
canv.drawImage("image.jpg", 100, height-100)
# position from the top of the image
canv.save()

Draw some basic Objects:

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.colors import red

canv = canvas.Canvas("hello4.pdf", pagesize=letter)
canv.setLineWidth(.3)

canv.setStrokeColor(red)
canv.line(100,100,100,200)

canv.setFillColor(red)
canv.rect(100,150,50, fill=1)
canv.circle(100, 200, 50, fill=1)
# don't forget that (0,0) is the anchor point
canv.save()
Photo
Add a comment...

Post has attachment
Add a comment...

Post has shared content
Add a comment...

Post has attachment
Wait while more posts are being loaded