Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw simple shapes and save to file (pdf)

Tags:

python

draw

I am looking for a python library that I can use to draw simple shapes and characters and then save to a file (in a format convertible to pdf). I would prefer if I did not need an X-server running.

E.g. could look something like this

import drawing_lib
obj = drawing_lib.Object()
for i in range(5):
    obj.draw_line(from=(i*10, 20), to=(i*10+10, 35))
obj.save_pdf('five_inclined_lines.pdf')

Any Ideas?

like image 918
Matthias 009 Avatar asked Jan 09 '12 17:01

Matthias 009


People also ask

How do I add shapes to a PDF for free?

To insert shapes, click the "Drawing Tools" icon and select the "Expand Drawing Tools". Step 3. Next, you can choose to add shapes like lines, arrows, ovals, rectangles, and many more according to your needs. If you do not like these shapes, you also can get many others from the Cloud and Polygon option.


1 Answers

There are several such libraries.

Personally I would recommend reportlab for its highly versatile nature.

like image 71
Roman Susi Avatar answered Sep 21 '22 20:09

Roman Susi