23 lines
735 B
Python
Executable File
23 lines
735 B
Python
Executable File
from PyPDF4 import PdfFileWriter, PdfFileReader
|
|
from pathlib import Path
|
|
import os
|
|
import sys
|
|
|
|
path= str(Path(__file__).resolve().parent) + "/matrices/"
|
|
|
|
def audit_waterMark(input_pdf, output_pdf):
|
|
watermark_pdf = path + "watermark_audit.pdf"
|
|
print("watermark_pdf = ",watermark_pdf)
|
|
watermark_instance = PdfFileReader(watermark_pdf)
|
|
watermark_page = watermark_instance.getPage(0)
|
|
|
|
# reads the input pdf file
|
|
pdf_reader = PdfFileReader(input_pdf)
|
|
pdf_writer = PdfFileWriter()
|
|
for page in range(pdf_reader.getNumPages()):
|
|
page = pdf_reader.getPage(page)
|
|
page.mergePage(watermark_page)
|
|
pdf_writer.addPage(page)
|
|
|
|
with open(output_pdf, 'wb') as out:
|
|
pdf_writer.write(out) |