added additional parameter to drawlink()
[swftools.git] / spec / textposition.py
blob4430716f7a893b132afff75f837d3597e49d4bca
1 from sys import *
2 from pdflib_py import *
3 from math import sin,cos
4 p = PDF_new()
5 PDF_open_file(p, "textposition.pdf")
7 PDF_set_parameter(p, "usercoordinates", "true")
9 width = 612
10 height = 500
11 PDF_begin_page(p, width, height)
13 font = PDF_load_font(p, "Helvetica-Bold", "host", "")
15 PDF_setfont(p, font, 18.0)
17 a=0.7
18 b=-0.7
19 matrices = [[1,0,0,1,100,200],
20 [cos(a),sin(a),-sin(a),cos(a),400,75],
21 [1,0,0,-1,100,350],
22 [-1,0,0,1,450,270],
23 [1.9,0.5,0.6,1.4,50,-140],
24 [cos(b),sin(b),sin(b),-cos(b),100,300],
25 [1.0,0,0,5,-90,-200],
28 for m in matrices:
29 PDF_save(p)
30 PDF_setmatrix(p, m[0],m[1],m[2],m[3],m[4],m[5])
31 x,y = 100,100
32 PDF_set_text_pos(p, x,y)
33 w = PDF_stringwidth(p, "HELLO WORLD", font, 18.0)
34 h = 18.0 - 4
35 PDF_setrgbcolor_fill(p, 0.0, 0.0, 0.0)
36 PDF_show(p, "HELLO WORLD")
38 PDF_setrgbcolor_fill(p, 0.0, 0.0, 1.0)
39 PDF_moveto(p, x,y)
40 PDF_lineto(p, x+w,y)
41 PDF_lineto(p, x+w,y+h)
42 PDF_lineto(p, x,y+h)
43 PDF_lineto(p, x,y)
44 PDF_moveto(p, x-20,y-20)
45 PDF_lineto(p, x-20,y+20+h)
46 PDF_lineto(p, x+20+w,y+20+h)
47 PDF_lineto(p, x+20+w,y-20)
48 PDF_lineto(p, x-20,y-20)
49 PDF_fill(p);
50 PDF_restore(p)
52 PDF_end_page(p)
53 PDF_close(p)
54 PDF_delete(p);