mirror of
https://github.com/kanzure/pdfparanoia.git
synced 2024-12-04 15:05:52 +01:00
Fixed a few bugs so reading from stdin now works. Involves a potentially costly recast of file contents as StringIO.
This commit is contained in:
parent
95e92420c9
commit
db514ff744
@ -16,7 +16,7 @@ if __name__ == "__main__":
|
||||
|
||||
ArgP = argparse.ArgumentParser(description="pdfparanoia is a PDF watermark removal library for academic papers. Some publishers include private information like institution names, personal names, ip addresses, timestamps and other identifying information in watermarks on each page.")
|
||||
ArgP.add_argument('in_pdf', nargs='?', type=argparse.FileType('rb'),
|
||||
default=sys.stdin)
|
||||
default='-') # argparse.FileType interprets "-" as Stdin.
|
||||
ArgP.add_argument("-o", "--output", type=argparse.FileType('wb'),
|
||||
default=sys.stdout)
|
||||
ArgP.add_argument("-v", "--verbose", action="store_true", default=False,
|
||||
@ -29,7 +29,9 @@ if __name__ == "__main__":
|
||||
if Args.verbose: verbose = 1
|
||||
if Args.more_verbose: verbose = 2
|
||||
|
||||
outputcontent = pdfparanoia.scrub(Args.in_pdf, verbose=verbose)
|
||||
# I really don't like having to read a file only to cast as StringIO, but seems
|
||||
# necessary to get reading from StdIn to play nicely with pdfparanoia.
|
||||
outputcontent = pdfparanoia.scrub(StringIO(Args.in_pdf.read()), verbose=verbose)
|
||||
Args.in_pdf.close()
|
||||
Args.output.write(outputcontent)
|
||||
if Args.output != sys.stdout:
|
||||
|
Loading…
Reference in New Issue
Block a user