合并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 

具体界面如下

相关推荐
小范馆16 分钟前
解决 Windows 11 安装时提示 “不支持 TPM 2.0” 和 “不支持安全启动” 的问题
windows·安全
还下着雨ZG21 分钟前
【Window技能 01】每天自动关机:使用CMD脚本+任务计划程序实现每天定时关闭计算机
windows
洛水如云40 分钟前
重塑数据管理逻辑!文件夹同步的实用指南(含工具选型 + 实操步骤)
windows·microsoft·电脑
石像鬼₧魂石1 小时前
windows系统139/tcp与445/tcp端口渗透完整流程闭环(复习总结)
windows·网络协议·tcp/ip
开开心心_Every2 小时前
强制打字练习工具:打够百字才可退出
java·游戏·微信·eclipse·pdf·excel·语音识别
BD_Marathon2 小时前
MyBatis——封装SqlSessionUtils工具类并测试功能
java·windows·mybatis
开开心心_Every2 小时前
多端免费远程控制工具:4K流畅同账号直连
游戏·macos·微信·pdf·excel·语音识别·phpstorm
洛水如云3 小时前
笔记本数据迁移新电脑:从备份到实操的高效指南(适用于台式机)
windows·microsoft·电脑
vortex53 小时前
Windows SeBackupPrivilege 与 SeRestorePrivilege 特权利用
windows
佑白雪乐3 小时前
<Python基础第2集>速通list+tuple+string+序列+set+dict容器
windows·python·list