Download app.py from EcarpayRH/GRADIO: direct link, hf CLI and curl.
- Browser
- Download file 631 Bytes
-
https://huggingface.co/EcarpayRH/GRADIO/resolve/refs%2Fpr%2F1/app.py
- Command line
-
hf download hf://EcarpayRH/GRADIO@refs/pr/1/app.py
-
curl -L -o app.py https://huggingface.co/EcarpayRH/GRADIO/resolve/refs%2Fpr%2F1/app.py
631 Bytes
| import gradio as gr | |
| import os | |
| def compress_pdf(input_pdf): | |
| output_pdf = f"{os.path.splitext(input_pdf.name)[0]}_comprimido.pdf" | |
| gs_command = f"gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile={output_pdf} {input_pdf.name}" | |
| os.system(gs_command) | |
| return output_pdf | |
| # Interface do Gradio | |
| interface = gr.Interface( | |
| fn=compress_pdf, | |
| inputs=gr.inputs.File(label="Upload your PDF"), | |
| outputs=gr.outputs.File(label="Download compressed PDF"), | |
| title="PDF Compressor", | |
| description="Compress your PDF files using Ghostscript" | |
| ) | |
| interface.launch() |