Changeset 16157 for main/waeup.kofa/trunk/src
- Timestamp:
- 9 Jul 2020, 13:25:01 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r16126 r16157 23 23 from time import time 24 24 from cStringIO import StringIO 25 from PyPDF2 import PdfFileMerger, PdfFileReader, PdfFileWriter 25 26 from reportlab.lib import colors 26 27 from reportlab.lib.units import cm … … 405 406 406 407 def setPaymentDetails(self, category, student, 407 previous_session , previous_level, combi=[]):408 previous_session=None, previous_level=None, combi=[]): 408 409 """Create a payment ticket and set the payment data of a 409 410 student for the payment category specified. … … 878 879 pre_text=None, post_text=None, 879 880 topMargin = 1.5, 880 letterhead_path=None): 881 letterhead_path=None, 882 mergefiles=None, watermark=None): 881 883 """Render pdf admission letter. 882 884 """ … … 936 938 note=post_text, topMargin=topMargin, 937 939 letterhead_path=letterhead_path) 940 if mergefiles: 941 merger = PdfFileMerger() 942 merger.append(StringIO(pdf_stream)) 943 if watermark: 944 watermark = PdfFileReader(watermark) 945 for file in mergefiles: 946 if watermark: 947 # Pass through all pages of each file 948 # and merge with watermark page. 949 marked_file = PdfFileWriter() 950 orig_file = PdfFileReader(file[1]) 951 num_pages = orig_file.getNumPages() 952 for num in range(num_pages): 953 page = orig_file.getPage(num) 954 page.mergePage(watermark.getPage(0)) 955 marked_file.addPage(page) 956 # Save into a file-like object 957 tmp1 = StringIO() 958 marked_file.write(tmp1) 959 # Append the file-like object 960 merger.append(tmp1) 961 else: 962 # Just append the file object 963 merger.append(file[1]) 964 # Save into a file-like object 965 tmp2 = StringIO() 966 merger.write(tmp2) 967 return tmp2.getvalue() 938 968 return pdf_stream 939 969
Note: See TracChangeset for help on using the changeset viewer.