- PDF文件分析
通過DC的分析,發(fā)現(xiàn)水印是通過/Artifact容器的形式添加飒箭,通過PyPDF2打印PDF的結(jié)構(gòu),對(duì)比5468發(fā)現(xiàn)位置。編寫代碼
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)