pdfparanoia/bin/pdfparanoia

38 lines
832 B
Python
Executable File

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
"""
pdfparanoia - pdf watermark removal tool
This is the command-line client. It accepts pdf formatted data either through
stdin/piping or by referencing a file in argv[0].
"""
if __name__ == "__main__":
import sys
import fileinput
from StringIO import StringIO
verbose = 0
while '--verbose' in sys.argv:
verbose += 1
sys.argv.pop(sys.argv.index('--verbose'))
while '-v' in sys.argv:
verbose += 1
sys.argv.pop(sys.argv.index('-v'))
import pdfparanoia
# read in all lines
content = ""
for line in fileinput.input():
content += line
# scrub the pdf to get rid of watermarks
output = pdfparanoia.scrub(StringIO(content), verbose=verbose)
# dump to output
sys.stdout.write(output)