@@ -39,8 +39,8 @@ def pisaErrorDocument(dest, c):
39
39
40
40
return pisaDocument (out .getvalue (), dest , raise_exception = False )
41
41
42
- def pisaStory (src , path = None , link_callback = None , debug = 0 , default_css = None ,
43
- xhtml = False , encoding = None , context = None , xml_output = None ,
42
+ def pisaStory (src , path = None , link_callback = None , debug = 0 , default_css = None ,
43
+ xhtml = False , encoding = None , context = None , xml_output = None ,
44
44
** kw ):
45
45
46
46
# Prepare Context
@@ -67,7 +67,7 @@ def pisaStory(src, path = None, link_callback = None, debug = 0, default_css = N
67
67
68
68
def pisaDocument (src , dest = None , path = None , link_callback = None , debug = 0 ,
69
69
default_css = None , xhtml = False , encoding = None , xml_output = None ,
70
- raise_exception = True , capacity = 100 * 1024 , ** kw ):
70
+ raise_exception = True , capacity = 100 * 1024 , ** kw ):
71
71
72
72
log .debug ("pisaDocument options:\n src = %r\n dest = %r\n path = %r\n link_callback = %r\n xhtml = %r" ,
73
73
src ,
@@ -81,21 +81,22 @@ def pisaDocument(src, dest=None, path=None, link_callback=None, debug=0,
81
81
context .pathCallback = link_callback
82
82
83
83
# Build story
84
- context = pisaStory (src , path , link_callback , debug , default_css , xhtml , encoding ,
85
- context = context , xml_output = xml_output )
84
+ context = pisaStory (src , path , link_callback , debug , default_css , xhtml ,
85
+ encoding , context = context , xml_output = xml_output )
86
86
87
87
# Buffer PDF into memory
88
88
out = pisaTempFile (capacity = context .capacity )
89
89
90
90
doc = PmlBaseDoc (
91
91
out ,
92
- pagesize = context .pageSize ,
93
- author = context .meta ["author" ].strip (),
94
- subject = context .meta ["subject" ].strip (),
95
- keywords = [x .strip () for x in context .meta ["keywords" ].strip ().split ("," ) if x ],
96
- title = context .meta ["title" ].strip (),
97
- showBoundary = 0 ,
98
- allowSplitting = 1 )
92
+ pagesize = context .pageSize ,
93
+ author = context .meta ["author" ].strip (),
94
+ subject = context .meta ["subject" ].strip (),
95
+ keywords = [x .strip () for x in
96
+ context .meta ["keywords" ].strip ().split ("," ) if x ],
97
+ title = context .meta ["title" ].strip (),
98
+ showBoundary = 0 ,
99
+ allowSplitting = 1 )
99
100
100
101
# Prepare templates and their frames
101
102
if context .templateList .has_key ("body" ):
@@ -107,11 +108,11 @@ def pisaDocument(src, dest=None, path=None, link_callback=None, debug=0,
107
108
id = "body" ,
108
109
frames = [
109
110
Frame (x , y , w , h ,
110
- id = "body" ,
111
- leftPadding = 0 ,
112
- rightPadding = 0 ,
113
- bottomPadding = 0 ,
114
- topPadding = 0 )],
111
+ id = "body" ,
112
+ leftPadding = 0 ,
113
+ rightPadding = 0 ,
114
+ bottomPadding = 0 ,
115
+ topPadding = 0 )],
115
116
pagesize = context .pageSize )
116
117
117
118
doc .addPageTemplates ([body ] + context .templateList .values ())
@@ -133,27 +134,27 @@ def _page_counter(page_no):
133
134
134
135
# Add watermarks
135
136
if pyPdf :
136
-
137
137
for bgouter in context .pisaBackgroundList :
138
-
139
138
# If we have at least one background, then lets do it
140
139
if bgouter :
141
-
142
140
istream = out
143
141
144
142
output = pyPdf .PdfFileWriter ()
145
143
input1 = pyPdf .PdfFileReader (istream )
146
144
ctr = 0
147
- #TODO: Why do we loop over the same list again? see bgouter at line 137
145
+ # TODO: Why do we loop over the same list again?
146
+ # see bgouter at line 137
148
147
for bg in context .pisaBackgroundList :
149
148
page = input1 .getPage (ctr )
150
- if bg and not bg .notFound () and (bg .mimetype == "application/pdf" ):
149
+ if (bg and not bg .notFound ()
150
+ and (bg .mimetype == "application/pdf" )):
151
151
bginput = pyPdf .PdfFileReader (bg .getFile ())
152
152
pagebg = bginput .getPage (0 )
153
153
pagebg .mergePage (page )
154
154
page = pagebg
155
155
else :
156
- log .warn (context .warning ("Background PDF %s doesn't exist." , bg ))
156
+ log .warn (context .warning (
157
+ "Background PDF %s doesn't exist." , bg ))
157
158
output .addPage (page )
158
159
ctr += 1
159
160
out = pisaTempFile (capacity = context .capacity )
0 commit comments