You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
581 B
22 lines
581 B
import os
|
|
|
|
import fitz
|
|
|
|
|
|
def add_watermask():
|
|
file_path = "./pdfs/girl.pdf"
|
|
water_path = "./waters/logo.png"
|
|
baseaname = os.path.basename(file_path)
|
|
name, suffix = os.path.splitext(baseaname)
|
|
out_path = os.path.join(os.path.dirname(file_path), name + "_watered" + suffix)
|
|
pdf_file = fitz.open(file_path)
|
|
page = pdf_file[0]
|
|
print(page.bound())
|
|
# page.insert_image(page.bound(), filename=water_path)
|
|
rect = (800, -100, 900, 0)
|
|
page.insert_image(rect, filename=water_path)
|
|
pdf_file.save(out_path)
|
|
|
|
|
|
add_watermask()
|