pip install pdfminer.six
import tkinter as tk
from tkinter import ttk, filedialog
from pdfminer.high_level import extract_text
def extract_tables_from_pdf(pdf_path):
text = extract_text(pdf_path)
lines = text.split('\n')
tables =
current_table =
for line in lines:
if not line.strip():
if current_table:
tables.append(current_table)
current_table =
else:
current_table.append(line)
if current_table:
tables.append(current_table)
return tables
def display_tables_in_tabs(all_tables):
root = tk.Tk()
root.title("PDF Tables Extractor")
notebook = ttk.Notebook(root)
notebook.pack(expand=1, fill="both")
for i, tables in enumerate(all_tables):
tab = ttk.Frame(notebook)
notebook.add(tab, text=f"PDF {i + 1}")
text_widget = tk.Text(tab, wrap='none')
text_widget.pack(expand=1, fill="both")
for table in tables:
for row in table:
text_widget.insert(tk.END, row + '\n')
text_widget.insert(tk.END, "="*50 + '\n')
root.mainloop()
def select_multiple_pdfs_and_extract_tables():
root = tk.Tk()
root.withdraw()
pdf_paths = filedialog.askopenfilenames(title="PDFファイルを選択してください", filetypes=[("PDF files", "*.pdf")])
all_tables =
for pdf_path in pdf_paths:
tables = extract_tables_from_pdf(pdf_path)
all_tables.append(tables)
display_tables_in_tabs(all_tables)
select_multiple_pdfs_and_extract_tables()