17 lines
355 B
Python
17 lines
355 B
Python
import io
|
|
import sys
|
|
from cropper import AutoSettings, auto_crop
|
|
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python test.py <pdf_path>")
|
|
sys.exit(1)
|
|
|
|
pdf_path = sys.argv[1]
|
|
with open(pdf_path, "rb") as fh:
|
|
content = io.BytesIO(fh.read())
|
|
|
|
buffer = auto_crop(content, AutoSettings())
|
|
|
|
with open("cropped.pdf", "wb") as fh:
|
|
fh.write(buffer.read())
|