合并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 小时前
Node.js配置生成器CLI工具开发实战
前端·人工智能·windows·前端框架·node.js·json
Lois_Luo3 小时前
关闭Win10强制所有应用以管理员身份运行
windows
luoyayun3614 小时前
实现Windows系统标题栏颜色跟随主题动态切换
windows·系统标题栏颜色·标题栏颜色
猫头虎5 小时前
如何解决 OpenClaw “Pairing required” 报错:两种官方解决方案详解
网络·windows·网络协议·macos·智能路由器·pip·scipy
呉師傅8 小时前
【使用技巧】Adobe Photoshop 2024调整缩放与布局125%后出现点菜单项漂移问题的简单处理
运维·服务器·windows·adobe·电脑·photoshop
梦帮科技9 小时前
OpenClaw 桥接调用 Windows MCP:打造你的 AI 桌面自动化助手
人工智能·windows·自动化
春日见11 小时前
如何创建一个PR
运维·开发语言·windows·git·docker·容器
C++ 老炮儿的技术栈11 小时前
VS2015 + Qt 实现图形化Hello World(详细步骤)
c语言·开发语言·c++·windows·qt
浩浩测试一下12 小时前
内网---> WriteOwner权限滥用
网络·汇编·windows·安全·microsoft·系统安全
一个人旅程~12 小时前
Dell n4020双系统分区步骤和linux优化操作
linux·windows·电脑