3 Star 1 Fork 2

Alex / document-converter

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

document-converter

项目发起初衷

近期有朋友要我帮忙将 pdf 格式文档数据提取成 docx 格式,平时我自己要么就通过编辑器转换了,要么就通过命令行转换,但这种方式对于一些朋友来说不是很友好,故此有此项目。

目前只支持 docx 和 pdf 互转,后续有时间了,会考虑支持多种常用文档格式互转,如果你对这感兴趣,欢迎提 PR !

项目特性

  • 使用 python3 编写的 docx、pdf 互转工具。
  • 支持多线程。
  • 支持跨平台(macOS、Windows、Linux)。
  • 批量 docx 文档转 pdf 格式(效果良好)。
  • 批量 pdf 文档转 docx 格式(尝试过多个扩展库,遗憾的是均不支持图片提取)。
  • 后续有时间了,会考虑支持多种常用的文档格式互转。

效果图

命令行提示

文档简介

批量 docx 转 pdf

docx转pdf

批量 pdf 转 docx

pdf转docx

使用方法

  1. 克隆源代码
# GitHub
git clone https://github.com/pudongping/document-converter.git

# gitee
git clone https://gitee.com/pudongping/document-converter.git
  1. 进入项目根目录,并安装相关依赖扩展
cd document-converter && sudo pip install -r requirements.txt
  1. 使用文档格式转换

举个例子来说,如果此时我想将 n.docx 格式的文档转换成 .pdf 格式的文档,那么我需要这么操作:

  • 将这 n.docx 文档复制到此项目的 data/input/docxs 目录(如果想转 .pdf 格式的文档,则需要将文档复制到 data/input/pdfs 目录)
  • 在项目根目录执行 python3 main.py --docx-to-pdf 命令,且等待命令执行结束(你可以去泡杯咖啡,之后静静等待,一般来说会很快,因为支持多线程)
  • 之后在 data/output/pdfs 目录查看已经转换好的文档。至此,完毕!
  1. 命令介绍
命令 说明
python3 main.py --version 显示当前应用的版本号
python3 main.py --help 或者 python3 main.py -h 显示帮助文档
python3 main.py --docx-to-pdf 执行 docx 文档转成 pdf 格式的文档
python3 main.py --pdf-to-docx 执行 pdf 文档转成 docx 格式的文档

项目目录介绍


├── LICENSE
├── Pipfile
├── README.md  项目介绍文档
├── app  代码目录
│   ├── __init__.py
│   ├── config  配置文件目录
│   │   ├── __init__.py
│   │   └── app.py  配置相关
│   ├── converter  转换相关代码目录
│   │   ├── __init__.py
│   │   ├── converter_docx.py  *文档转 docx 格式相关代码
│   │   └── converter_pdf.py   *文档转 pdf 格式相关代码
│   └── helper.py  助手函数
├── data  数据相关
│   ├── input  需要转换的文档目录
│   │   ├── docxs  如果需要将 docx 文档转换成其他格式,则默认需要将文档放入此目录下
│   │   │   ├── 文档1.docx
│   │   │   └── 文档2.docx
│   │   └── pdfs  如果需要将 pdf 文档转换成其他格式,则默认需要将文档放入此目录下
│   │       ├── alex1.pdf
│   │       └── sample.pdf
│   └── output  文档转换后存放的文档目录
│       ├── docxs  所有经过转换后的 docx 文档默认会放到此目录下
│       │   ├── alex1.pdf.docx
│       │   └── sample.pdf.docx
│       └── pdfs  所有经过转换后的 pdf 文档默认会放到此目录下
│           ├── 文档1.docx.pdf
│           └── 文档2.docx.pdf
├── main.py  项目入口文件
├── requirements.txt  项目依赖关系清单
└── runtime  项目运行相关
    └── logs  日志目录
        └── 202104
            └── converter-2021-04-24.log  以天为单位记录的操作日志

License

源代码基于 MIT 协议发布。

MIT License Copyright (c) 2021 pudongping Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

使用 python3 写的 docx、excel、ppt 转 pdf 工具 展开 收起
Python
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/pudongping/document-converter.git
git@gitee.com:pudongping/document-converter.git
pudongping
document-converter
document-converter
master

搜索帮助