- PDF文件分析
通过DC的分析,发现水印是通过/Artifact容器的形式添加,通过PyPDF2打印PDF的结构,对比5468发现位置。编写代码
from PyPDF2 import PdfFileReader, PdfFileWriter
def remove_watermark(input_file, output_file):
with open(input_file, "rb") as f:
source = PdfFileReader(f, "rb")
output = PdfFileWriter()
for page in range(source.getNumPages()):
page = source.getPage(page)
#print(type(page))
#print(type(page['/Resources']['/XObject']['/Fm0']))
page['/Resources']['/XObject']['/Fm0'].setData(b'')
output.addPage(page)
# 输入新的pdf文件
with open(output_file, "wb") as outputStream:
output.write(outputStream)