Changeset 16262 for main/waeup.kofa/trunk/src/waeup/kofa/browser
- Timestamp:
- 1 Oct 2020, 06:51:10 (4 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/browser
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py
r16149 r16262 23 23 import os 24 24 import pytz 25 from string import Template 25 26 from cStringIO import StringIO 26 27 from datetime import datetime … … 559 560 logo_left_pos = [0, 0, 0] 560 561 pagesize = portrait(A4) 562 563 test_signature_img_path = os.path.join( 564 os.path.dirname(__file__), 'static', 'test_signature.png') 561 565 562 566 @classmethod … … 823 827 return 824 828 829 def _substitute_markers(self, text): 830 """If `text` contains some marker, substitute it. 831 832 Markers are standard library string template placeholders. See 833 https://docs.python.org/2/library/string.html and 834 `string.Template` for details. Roughly, placeholders look like 835 ``${some_marker}``. 836 837 Valid markers: 838 ``test_signature_img_path`` -- path to signature image stored in 839 `test_signature_img_path`` attribute. 840 """ 841 text = Template(text) 842 PDF_SIGNATURES = { 843 'test_signature_img_path': self.test_signature_img_path, 844 } 845 return text.safe_substitute(PDF_SIGNATURES) 846 825 847 def create_pdf(self, data, headerline=None, title=None, author=None, 826 848 footer='', note=None, sigs_in_footer=[], topMargin=1.5, … … 849 871 doc.letterhead_path = letterhead_path 850 872 if note is not None: 873 # Inject signature images 874 note = self._substitute_markers(note) 875 # Format html 851 876 html = format_html(note) 852 877 data.append(Paragraph(html, NOTE_STYLE))
Note: See TracChangeset for help on using the changeset viewer.