合并pdf工具下载

csdn上面的下载链接如下

https://download.csdn.net/download/weixin_46756664/91434934?spm=1011.2124.3001.6210

百度网盘链接如下

链接: https://pan.baidu.com/s/1z4lpDGNxKQKW8Zi5A0pgew?pwd=2s9r 提取码: 2s9r

源码如下pdf_merger_app.py(deepseek自动生成的)

python 复制代码
import os
import tkinter as tk
from tkinter import filedialog, messagebox, Listbox, Scrollbar, MULTIPLE, END
from PyPDF2 import PdfMerger

class PDFMergerApp:
    def __init__(self, root):
        self.root = root
        self.root.title("PDF合并工具")
        self.root.geometry("600x500")
        
        # 文件列表
        self.file_list = []
        
        # 创建UI组件
        self.create_widgets()
    
    def create_widgets(self):
        # 添加文件按钮
        tk.Button(self.root, text="添加PDF文件", command=self.add_files, height=2, bg="#4CAF50", fg="white").pack(pady=10, fill=tk.X, padx=20)
        
        # 文件列表框
        list_frame = tk.Frame(self.root)
        list_frame.pack(pady=5, fill=tk.BOTH, expand=True, padx=20)
        
        scrollbar = Scrollbar(list_frame)
        scrollbar.pack(side=tk.RIGHT, fill=tk.Y)
        
        self.listbox = Listbox(
            list_frame, 
            selectmode=MULTIPLE,
            yscrollcommand=scrollbar.set,
            height=10
        )
        self.listbox.pack(fill=tk.BOTH, expand=True)
        scrollbar.config(command=self.listbox.yview)
        
        # 移除按钮
        tk.Button(self.root, text="移除选中文件", command=self.remove_files, height=2, bg="#f44336", fg="white").pack(pady=5, fill=tk.X, padx=20)
        
        # 输出路径
        path_frame = tk.Frame(self.root)
        path_frame.pack(pady=10, fill=tk.X, padx=20)
        
        tk.Label(path_frame, text="输出路径:").pack(side=tk.LEFT)
        self.path_var = tk.StringVar()
        tk.Entry(path_frame, textvariable=self.path_var, width=40).pack(side=tk.LEFT, padx=5, fill=tk.X, expand=True)
        tk.Button(path_frame, text="浏览", command=self.select_output_path).pack(side=tk.RIGHT)
        
        # 输出文件名
        name_frame = tk.Frame(self.root)
        name_frame.pack(pady=5, fill=tk.X, padx=20)
        
        tk.Label(name_frame, text="输出文件名:").pack(side=tk.LEFT)
        self.name_var = tk.StringVar(value="merged.pdf")
        tk.Entry(name_frame, textvariable=self.name_var, width=40).pack(side=tk.LEFT, padx=5, fill=tk.X, expand=True)
        
        # 合并按钮
        tk.Button(self.root, text="合并PDF文件", command=self.merge_pdfs, height=2, bg="#2196F3", fg="white", font=("Arial", 12, "bold")).pack(pady=20, fill=tk.X, padx=20)
    
    def add_files(self):
        files = filedialog.askopenfilenames(
            title="选择PDF文件",
            filetypes=[("PDF文件", "*.pdf"), ("所有文件", "*.*")]
        )
        if files:
            self.file_list.extend(files)
            self.update_listbox()
    
    def remove_files(self):
        selected = self.listbox.curselection()
        if selected:
            # 从后往前删除避免索引变化
            for index in sorted(selected, reverse=True):
                del self.file_list[index]
            self.update_listbox()
    
    def update_listbox(self):
        self.listbox.delete(0, END)
        for file in self.file_list:
            self.listbox.insert(END, os.path.basename(file))
    
    def select_output_path(self):
        path = filedialog.askdirectory(title="选择输出文件夹")
        if path:
            self.path_var.set(path)
    
    def merge_pdfs(self):
        if not self.file_list:
            messagebox.showwarning("警告", "请至少添加一个PDF文件!")
            return
        
        output_path = self.path_var.get()
        if not output_path:
            messagebox.showwarning("警告", "请选择输出路径!")
            return
        
        output_name = self.name_var.get().strip()
        if not output_name:
            messagebox.showwarning("警告", "请输入输出文件名!")
            return
        if not output_name.lower().endswith('.pdf'):
            output_name += '.pdf'
        
        output_file = os.path.join(output_path, output_name)
        
        try:
            merger = PdfMerger()
            
            for pdf in self.file_list:
                merger.append(pdf)
            
            with open(output_file, 'wb') as f:
                merger.write(f)
            
            messagebox.showinfo("成功", f"PDF文件合并成功!\n保存位置: {output_file}")
        except Exception as e:
            messagebox.showerror("错误", f"合并过程中发生错误:\n{str(e)}")
        finally:
            merger.close()

if __name__ == "__main__":
    root = tk.Tk()
    app = PDFMergerApp(root)
    root.mainloop()

需要安装的库如下

python 复制代码
pip install PyPDF2 tkinter pyinstaller

生成exe脚本如下

java 复制代码
pyinstaller --onefile --windowed --name="pdf合并" pdf_merger_app.py 

具体界面如下

相关推荐
埃博拉酱3 天前
VS Code Remote SSH 连接 Windows 服务器卡在"下载 VS Code 服务器":prcdn DNS 解析失败的诊断与 BITS 断点续传
windows·ssh·visual studio code
唐宋元明清21883 天前
.NET 本地Db数据库-技术方案选型
windows·c#
加号33 天前
windows系统下mysql多源数据库同步部署
数据库·windows·mysql
tryCbest3 天前
Windows环境下配置pip镜像源
windows·pip
呉師傅3 天前
火狐浏览器报错配置文件缺失如何解决#操作技巧#
运维·网络·windows·电脑
百事牛科技3 天前
保护文档安全:PDF限制功能详解与实操
windows·pdf
一个人旅程~3 天前
如何用命令行把win10/win11设置为长期暂停更新?
linux·windows·经验分享·电脑
一个假的前端男4 天前
[特殊字符] Flutter 安装完整指南 Windows—— 2026最新版
windows·flutter
倚肆4 天前
在 Windows Docker 中安装并配置 Nginx (映射 Windows 端口与路径)
windows·nginx·docker
破无差4 天前
拯救你的C盘
windows