File manager - Edit - /home/wwcana/ficha.canabravavacationclub.com.br/servidor_py/app.py
Back
from flask import Flask, request import PyPDF2 import os import sys def convert_pdf_to_v1_4(input_path, output_path): # Open the input PDF file with open(input_path, 'rb') as input_file: # Create a PDF reader object reader = PyPDF2.PdfReader(input_file) # Create a PDF writer object writer = PyPDF2.PdfWriter() # Iterate over each page in the input PDF for page_num in range(len(reader.pages)): # Get the page at the specified index page = reader.pages[page_num] # Add the page to the writer object writer.add_page(page) # Open the output PDF file with open(output_path, 'wb') as output_file: # Set the PDF version in the output file's trailer writer._root_object.update({ PyPDF2.generic.NameObject('/Version'): PyPDF2.generic.create_string_object('(1.4)') }) # Write the modified PDF to the output file writer.write(output_file) app = Flask(__name__) @app.route('/') def hello(): folder = request.args.get('value') input_folder_path = '../storage/app/public/' + folder for filename in os.listdir(input_folder_path): if filename.lower().endswith('.pdf'): input_file_path = os.path.join(input_folder_path, filename) output_file_path = os.path.join(input_folder_path, filename) convert_pdf_to_v1_4(input_file_path, output_file_path) return 'Hello, Flask! The value passed is: ' + input_folder_path if __name__ == '__main__': app.run(port=3000, debug=True)
| ver. 1.4 |
Github
|
.
| PHP 5.6.40 | Generation time: 0 |
proxy
|
phpinfo
|
Settings