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

具体界面如下

相关推荐
ö Constancy1 小时前
一台电脑的硬件组成与作用:按功能分类详解(Windows 与 Linux 视角)
linux·windows·电脑
w3296362711 小时前
飞书接单到月度结算:我用一个 DSH 插件跑通鞋类采购 WMS,附 22 项验收
pdf·node.js·飞书·后端开发·ai agent
雪落漂泊1 天前
Liunux进程(七):程序控制篇(中)
linux·运维·windows
承渊政道2 天前
Fooocus本地AI绘图教程:Windows部署、低门槛生图与远程访问
人工智能·windows·cpolar·fooocus·生图
陈工大模型2 天前
收到乱码压缩包之后,我重新测了 7-Zip、Bandizip 和win解压缩
windows·电脑·软件工程·软件需求·7-zip
谙弆悕博士2 天前
在文件夹右键直接打开 Kali WSL:一条 `wsl --cd` 注册表脚本
windows·脚本·wsl·右击·ksli
陈工大模型2 天前
解压工具的三个技术分水岭:编码、分卷、容器格式
人工智能·windows·安全·解压工具·免费国内办公软件
小熊熊知识库3 天前
双层PDF转换软件
pdf·双层pdf转换
Zucker n3 天前
文献发现、课题组织与证据可追溯的论文阅读。
论文阅读·windows·ubuntu
flyingonpine4 天前
PowerShell脚本数字签名实战:自签名证书、代码签名与信任链验证
windows·信任链