Changeset 12184 for main/waeup.ikoba/trunk
- Timestamp:
- 9 Dec 2014, 15:58:08 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba/customers
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12182 r12184 22 22 import grok 23 23 import pytz 24 import os 24 25 from urllib import urlencode 25 26 from datetime import datetime … … 1040 1041 self.request, self.omit_fields) 1041 1042 customers_utils = getUtility(ICustomersUtils) 1043 if self.context.state == VERIFIED: 1044 watermark_path = os.path.join( 1045 os.path.dirname(__file__), 'static', 'verified.pdf') 1046 else: 1047 watermark_path = os.path.join( 1048 os.path.dirname(__file__), 'static', 'unverified.pdf') 1049 watermark = open(watermark_path, 'rb') 1042 1050 return customers_utils.renderPDF( 1043 1051 self, 'pdfdocument_slip.pdf', 1044 1052 self.context.customer, customerview, 1045 1053 omit_fields=self.omit_fields, 1046 mergefiles=self.context.connected_files) 1054 mergefiles=self.context.connected_files, 1055 watermark=watermark) 1047 1056 1048 1057 # Pages for customer contracts -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py
r12182 r12184 337 337 note=None, signatures=None, sigs_in_footer=(), 338 338 show_scans=True, show_history=True, topMargin=1.5, 339 omit_fields=(), mergefiles=None ):339 omit_fields=(), mergefiles=None, watermark=None): 340 340 """Render pdf slips for various pages. 341 341 """ … … 426 426 merger = PdfFileMerger() 427 427 merger.append(StringIO(pdf_stream)) 428 if watermark: 429 watermark = PdfFileReader(watermark) 428 430 for file in mergefiles: 429 merger.append(file[1]) 430 tmp = StringIO() 431 merger.write(tmp) 432 return tmp.getvalue() 431 if watermark: 432 # Pass through all pages of each file 433 # and merge with watermark page. 434 marked_file = PdfFileWriter() 435 orig_file = PdfFileReader(file[1]) 436 num_pages = orig_file.getNumPages() 437 for num in range(num_pages): 438 page = orig_file.getPage(num) 439 page.mergePage(watermark.getPage(0)) 440 marked_file.addPage(page) 441 # Save into a file-like object 442 tmp1 = StringIO() 443 marked_file.write(tmp1) 444 # Append the file-like object 445 merger.append(tmp1) 446 else: 447 # Just append the file object 448 merger.append(file[1]) 449 # Save into a file-like object 450 tmp2 = StringIO() 451 merger.write(tmp2) 452 return tmp2.getvalue() 433 453 434 454 return pdf_stream
Note: See TracChangeset for help on using the changeset viewer.