# pdf_converter **Repository Path**: cgdev/pdf_converter ## Basic Information - **Project Name**: pdf_converter - **Description**: python将彩色pdf转成黑白 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-12 - **Last Updated**: 2026-02-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # python编程将彩色pdf转成黑白的 使用PyMuPDF(也称为fitz)库来处理PDF文件,将彩色PDF转换为黑白(灰度)。 ## 步骤 ### 安装虚拟环境 ```bash python -m venv venv ``` ### 激活虚拟环境 ```bash venv\script\activate.bat ``` ### 安装PyMuPDF库 ```bash pip install PyMuPDF ``` ### 运行 ```bash python pdf_convertet_gui.py ``` ### 程序界面 ![程序界面](img/pic01.png) 读取PDF文件,将每一页转换为灰度图像,然后再保存为PDF。 >注意:这种方法可能会丢失一些非图像的内容(如文字)的矢量信息,因为我们将页面转换为了图像。 1. 打开PDF文件。 2. 遍历每一页,将页面渲染为图像(灰度)。 3. 将图像保存为新的PDF页面。