X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=spec%2Ftextposition.py;fp=spec%2Ftextposition.py;h=4430716f7a893b132afff75f837d3597e49d4bca;hp=0000000000000000000000000000000000000000;hb=0e9d27093c3e6e8e316fbc08bb9d422d74da2fd1;hpb=ecd7c7248b9a93163090bfe7512b2a53d8da6d95 diff --git a/spec/textposition.py b/spec/textposition.py new file mode 100644 index 0000000..4430716 --- /dev/null +++ b/spec/textposition.py @@ -0,0 +1,54 @@ +from sys import * +from pdflib_py import * +from math import sin,cos +p = PDF_new() +PDF_open_file(p, "textposition.pdf") + +PDF_set_parameter(p, "usercoordinates", "true") + +width = 612 +height = 500 +PDF_begin_page(p, width, height) + +font = PDF_load_font(p, "Helvetica-Bold", "host", "") + +PDF_setfont(p, font, 18.0) + +a=0.7 +b=-0.7 +matrices = [[1,0,0,1,100,200], + [cos(a),sin(a),-sin(a),cos(a),400,75], + [1,0,0,-1,100,350], + [-1,0,0,1,450,270], + [1.9,0.5,0.6,1.4,50,-140], + [cos(b),sin(b),sin(b),-cos(b),100,300], + [1.0,0,0,5,-90,-200], + ] + +for m in matrices: + PDF_save(p) + PDF_setmatrix(p, m[0],m[1],m[2],m[3],m[4],m[5]) + x,y = 100,100 + PDF_set_text_pos(p, x,y) + w = PDF_stringwidth(p, "HELLO WORLD", font, 18.0) + h = 18.0 - 4 + PDF_setrgbcolor_fill(p, 0.0, 0.0, 0.0) + PDF_show(p, "HELLO WORLD") + + PDF_setrgbcolor_fill(p, 0.0, 0.0, 1.0) + PDF_moveto(p, x,y) + PDF_lineto(p, x+w,y) + PDF_lineto(p, x+w,y+h) + PDF_lineto(p, x,y+h) + PDF_lineto(p, x,y) + PDF_moveto(p, x-20,y-20) + PDF_lineto(p, x-20,y+20+h) + PDF_lineto(p, x+20+w,y+20+h) + PDF_lineto(p, x+20+w,y-20) + PDF_lineto(p, x-20,y-20) + PDF_fill(p); + PDF_restore(p) + +PDF_end_page(p) +PDF_close(p) +PDF_delete(p);