import gradio as gr import pandas as pd from parse_perfect_metaprint import parse_perfect_metaprint from parse_toshiba import parse_toshiba_pdf from parse_bhel import parse_bhel_pdf def process_pdf(file, format_type): # Select the appropriate parser based on format type if format_type == "Perfect Meta Print": df = parse_perfect_metaprint(file.name) elif format_type == "Toshiba": df = parse_toshiba_pdf(file.name) elif format_type == "BHEL": df = parse_bhel_pdf(file.name) else: return "Unsupported format selected", None # Save the DataFrame to an Excel file output_file = f"{format_type}_Data.xlsx" df.to_excel(output_file, index=False) return output_file # Gradio Interface iface = gr.Interface( fn=process_pdf, inputs=[ gr.inputs.File(label="Upload PDF"), gr.inputs.Dropdown(choices=["Perfect Meta Print", "Toshiba", "BHEL"], label="Select Format") ], outputs=gr.outputs.File(label="Download Excel") ) if __name__ == "__main__": iface.launch()