Bernd Wurst commited on 2009-01-14 09:17:42
Zeige 2 geänderte Dateien mit 35 Einfügungen und 19 Löschungen.
... | ... |
@@ -1,6 +1,10 @@ |
1 | 1 |
# -* coding: utf8 *- |
2 | 2 |
from metrics import * |
3 | 3 |
|
4 |
+ |
|
5 |
+address_header = 'schokokeks.org · Köchersberg 25 · 71540 Murrhardt' |
|
6 |
+ |
|
7 |
+ |
|
4 | 8 |
def FoldingMarkers(canvas): |
5 | 9 |
"""Setzt Falzmarken""" |
6 | 10 |
from reportlab.lib.units import cm |
... | ... |
@@ -30,24 +34,6 @@ def Footer(canvas): |
30 | 34 |
canvas.drawString(leftcontent+((rightcontent-leftcontent)/3)*2, bottomcontent-40, 'BIC: GENODES1VBK') |
31 | 35 |
|
32 | 36 |
|
33 |
-def address(canvas, lines): |
|
34 |
- x = 2.0 * cm |
|
35 |
- y = page_height - 5.0*cm |
|
36 |
- canvas.setFont(font, 8) |
|
37 |
- canvas.drawString(x+0.5*cm, y+0.1*cm, 'schokokeks.org · Köchersberg 25 · 71540 Murrhardt') |
|
38 |
- canvas.setLineWidth(1) |
|
39 |
- canvas.line(x+0.4*cm, y, x + address_width, y) |
|
40 |
- y = y - 0.2*cm |
|
41 |
- |
|
42 |
- line_height = 11 + 0.1*cm |
|
43 |
- y -= line_height |
|
44 |
- canvas.setFont(font, 11) |
|
45 |
- for line in lines: |
|
46 |
- canvas.drawString(x+0.5*cm, y, line) |
|
47 |
- y -= line_height |
|
48 |
- |
|
49 |
- |
|
50 |
- |
|
51 | 37 |
def basicPage(canvas): |
52 | 38 |
FoldingMarkers(canvas) |
53 | 39 |
Footer(canvas) |
... | ... |
@@ -6,7 +6,7 @@ import re |
6 | 6 |
# our page size and margins |
7 | 7 |
from metrics import * |
8 | 8 |
# our custom page style |
9 |
-from custom_elements import basicPage, firstPage, address |
|
9 |
+from custom_elements import basicPage, firstPage, address_header |
|
10 | 10 |
|
11 | 11 |
# reportlab imports |
12 | 12 |
from reportlab.lib.units import cm |
... | ... |
@@ -86,6 +86,36 @@ def _PageWrap(canvas): |
86 | 86 |
basicPage(canvas) |
87 | 87 |
|
88 | 88 |
|
89 |
+def address(canvas, lines): |
|
90 |
+ x = 2.0 * cm |
|
91 |
+ y = page_height - 5.0*cm |
|
92 |
+ canvas.setFont(font, 8) |
|
93 |
+ canvas.drawString(x+0.5*cm, y+0.1*cm, 'schokokeks.org · Köchersberg 25 · 71540 Murrhardt') |
|
94 |
+ canvas.setLineWidth(1) |
|
95 |
+ canvas.line(x+0.4*cm, y, x + address_width, y) |
|
96 |
+ y = y - 0.2*cm |
|
97 |
+ |
|
98 |
+ line_height = 11 + 0.1*cm |
|
99 |
+ y -= line_height |
|
100 |
+ canvas.setFont(font, 11) |
|
101 |
+ for line in lines: |
|
102 |
+ fontsize = 11 |
|
103 |
+ if canvas.stringWidth(line, font, fontsize) > address_width: |
|
104 |
+ # Wenn es in zwei Zeilen passt, dann ist alles okay, ansonsten verkleinern |
|
105 |
+ if canvas.stringWidth(line, font, fontsize) > 2*address_width: |
|
106 |
+ for fontsize in [10.5, 10, 9.5, 9, 8.5]: |
|
107 |
+ if canvas.stringWidth(line, font, fontsize) <= 2*address_width: |
|
108 |
+ break |
|
109 |
+ mylines = _splitToWidth(canvas, line, address_width, font, fontsize) |
|
110 |
+ for l in mylines: |
|
111 |
+ canvas.drawString(x+0.5*cm, y, l) |
|
112 |
+ y -= line_height |
|
113 |
+ else: |
|
114 |
+ canvas.drawString(x+0.5*cm, y, line) |
|
115 |
+ y -= line_height |
|
116 |
+ |
|
117 |
+ |
|
118 |
+ |
|
89 | 119 |
|
90 | 120 |
def InvoiceToPDF(iv): |
91 | 121 |
from StringIO import StringIO |
92 | 122 |