Changeset 16159 for main


Ignore:
Timestamp:
10 Jul 2020, 06:11:44 (4 years ago)
Author:
Henrik Bettermann
Message:

Paint watermark first to make it transparent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r16158 r16159  
    2020import grok
    2121import textwrap
     22from copy import deepcopy
    2223from cgi import escape
    2324from time import time
     
    941942            merger = PdfFileMerger()
    942943            merger.append(StringIO(pdf_stream))
    943             if watermark:
    944                 watermark = PdfFileReader(watermark)
    945944            for file in mergefiles:
    946945                if watermark:
    947946                    # Pass through all pages of each file
    948                     # and merge with watermark page.
     947                    # and merge with watermark page. Paint
     948                    # watermark first to make it transparent.
    949949                    marked_file = PdfFileWriter()
    950950                    orig_file = PdfFileReader(file)
    951951                    num_pages = orig_file.getNumPages()
    952952                    for num in range(num_pages):
    953                         page = orig_file.getPage(num)
    954                         page.mergePage(watermark.getPage(0))
     953                        watermark_file = PdfFileReader(watermark)
     954                        page = watermark_file.getPage(0)
     955                        page.mergePage(orig_file.getPage(num))
    955956                        marked_file.addPage(page)
    956957                    # Save into a file-like object
     
    961962                else:
    962963                    # Just append the file object
    963                     merger.append(file[1])
     964                    merger.append(file)
    964965            # Save into a file-like object
    965966            tmp2 = StringIO()
Note: See TracChangeset for help on using the changeset viewer.