Skip to content

Commit

Permalink
Support both older and newer fitz versions
Browse files Browse the repository at this point in the history
They renamed functions...
  • Loading branch information
mhagander committed Dec 13, 2024
1 parent d3735cc commit d691c9a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions postgresqleu/digisign/pdfutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def fill_pdf_fields(pdf, available_fields, fielddata):
txt = ""

if txt:
page.insertText(p, txt, fontname='Courier-Bold', fontsize=fielddata['fontsize'])
if fitz.version[0] > "1.19":
page.insert_text(p, txt, fontname='Courier-Bold', fontsize=fielddata['fontsize'])
else:
page.insertText(p, txt, fontname='Courier-Bold', fontsize=fielddata['fontsize'])

return pdf.write()

Expand Down Expand Up @@ -69,6 +72,9 @@ def pdf_watermark_preview(pdfdata):

pdf = fitz.open('pdf', pdfdata)
for pagenum, page in enumerate(pdf.pages()):
page.insertImage(page.bound(), pixmap=wmpixmap, overlay=False)
if fitz.version[0] > "1.19":
page.insert_image(page.bound(), pixmap=wmpixmap, overlay=False)
else:
page.insertImage(page.bound(), pixmap=wmpixmap, overlay=False)

return pdf.write()

0 comments on commit d691c9a

Please sign in to comment.