diff --git "a/docs/2021-01-02-Python\345\244\204\347\220\206PDF\347\232\204\347\254\254\344\270\211\346\226\271\345\272\223\345\257\271\346\257\224.md" "b/docs/2021-01-02-Python\345\244\204\347\220\206PDF\347\232\204\347\254\254\344\270\211\346\226\271\345\272\223\345\257\271\346\257\224.md" index f18a1d2..795f364 100644 --- "a/docs/2021-01-02-Python\345\244\204\347\220\206PDF\347\232\204\347\254\254\344\270\211\346\226\271\345\272\223\345\257\271\346\257\224.md" +++ "b/docs/2021-01-02-Python\345\244\204\347\220\206PDF\347\232\204\347\254\254\344\270\211\346\226\271\345\272\223\345\257\271\346\257\224.md" @@ -8,15 +8,17 @@ tags: [python] --- +*2022.06.07修订:新增第三方库`borb`。初稿写于2021.01.02,彼时`borb`才发布1.0版没几个月;两年不到,Github上已近三千赞。* + PDF(Portable Document Format)是一种便携文档格式,便于跨操作系统传播文档。PDF文档遵循标准格式,因此存在很多可以操作PDF文档的工具,Python自然也不例外。面多众多的Python第三方库,本文从功能、开源协议及社区活跃度三方面加以对比,以便根据具体需求选择合适的库。 ## 概况 -功能对比从大粒度上分成了`提取内容`、`操作页面`和`创建内容`三方面。前两者分别是针对已经存在的PDF文档的读和写操作,最后一项从内容上创建新文档。考虑到时效性,以下对比列出了撰文时相应的最新版本。 +功能对比从大粒度上分成了 **提取内容**、**操作页面** 和 **创建内容** 三方面。前两者分别是针对已经存在的PDF文档的读和写操作,最后一项从内容上创建新文档。考虑到时效性,以下对比列出了撰文时(2021.01)相应的最新版本。 -- `提取内容`如文本、图片、元信息 -- `操作页面`特指操作已经存在的页面例如分割、合并、裁剪、旋转等 -- `创建内容`指创建或修改页面内容,例如文本、图片、形状 +- **提取内容** 如文本、图片、元信息 +- **操作页面** 特指操作已经存在的页面例如分割、合并、裁剪、旋转等 +- **创建内容** 指创建或修改页面内容,例如文本、图片、形状 Python库 | 当前版本 | Python版本 | 开源协议 | 最新更新 | 功能:提取内容 | 功能:操作页面 | 功能:创建内容 | 备注 @@ -28,15 +30,23 @@ Python库 | 当前版本 | Python版本 | 开源协议 | 最新更新 | 功能 [pdfplumber](https://github.com/jsvine/pdfplumber) | 0.5.25 | 3.6-3.8 | MIT | 活跃 | √ | × | × | 基于`pdfminer.six`;除了文本、形状(矩形、直线/曲线),还能**解析表格**。*几个提取PDF表格的Python库的对比参考[此处](https://github.com/atlanhq/camelot/wiki/Comparison-with-other-PDF-Table-Extraction-libraries-and-tools#pdf-table-extract)* [pdfminer.six](https://github.com/pdfminer/pdfminer.six) | 20201018 | 3.6+ | MIT | 2个月前 | √ | × | × | [`pdfminer`](https://github.com/euske/pdfminer/)的社区维护版,因为`pdfminer`自2020年起不再积极维护 [PyMuPDF](https://github.com/pymupdf/PyMuPDF) | 1.18.5 | 3.6+ | GPL V3 | 非常活跃 | √ | √ | √ | 基于[`mupdf`](https://mupdf.com/);以处理速度著称,参考[此处](https://pymupdf.readthedocs.io/en/latest/app1.html) +[borb](https://github.com/jorisschellekens/borb) | 2.0.27 | 3.6+ | AGPL | 非常活跃 | √ | √ | √ | 纯Python库,支持读、写、操作PDF文档,兼顾底层和高级应用 + +*`borb`于 2022.06 新加入对比,时间点以此为准。* ## 点评 - `PyPDF2`系列、`pdfrw`及`pikepdf`专注对已经存在的PDF的操作(分割、合并、旋转等),前两者基本处于停止维护的状态。 + - `pdfplumber`及其依赖`pdfminer.six`专注PDF内容提取,例如文本(位置、字体及颜色等)和形状(矩形、直线、曲线),前者还有解析表格的功能。 + - `ReportLab`专注PDF页面内容(文本、图、表等)的创建。 -- `PyMuPDF`功能全面且速度快,但是`GPL v3`的开源协议对商用不友好。 + +- `PyMuPDF`和`borb`同时支持读、写及PDF页面操作,功能最为全面。其中,`PyMuPDF`尤其以速度快著称,而`borb`是新开发并深得好评的库,潜力无穷。但是,二者同为`GPL`家族的开源协议,对商用不太友好*。 + +`*` *支持免费使用,但是要求引用其的程序也必须遵守相应协议即开源。如果需要闭源使用的话,需要向作者申请付费的商用授权。* 最后,用下图的总结结束全文。 -![](images/2021-01-02-01.png) \ No newline at end of file +![](images/2021-01-02-01.drawio.png) \ No newline at end of file diff --git "a/docs/2022-01-27-GitLab-CI-CD\357\274\232\350\247\246\345\217\221\350\267\250\351\241\271\347\233\256pipeline.md" "b/docs/2022-01-27-GitLab-CI-CD\357\274\232\350\247\246\345\217\221\350\267\250\351\241\271\347\233\256pipeline.md" index b9f3b0a..78878ef 100644 --- "a/docs/2022-01-27-GitLab-CI-CD\357\274\232\350\247\246\345\217\221\350\267\250\351\241\271\347\233\256pipeline.md" +++ "b/docs/2022-01-27-GitLab-CI-CD\357\274\232\350\247\246\345\217\221\350\267\250\351\241\271\347\233\256pipeline.md" @@ -22,7 +22,7 @@ tags: [GitLab] 为简化表述,用`A`表示发布仓库,分别用`B1`、`B2`表示前、后端仓库,则可用下图表示以上流程。 -![general-flow](images/2022-01-27-01.png) +![general-flow](images/2022-01-27-01.drawio.png) ## 具体流程 @@ -43,7 +43,7 @@ tags: [GitLab] 类似上文所述`A`的流程,只不过此时需要根据原始仓库(即`B1`)确定只触发`B1`的流程,进而来到`B1`的`build`。 -![detail-flow](images/2022-01-27-02.png) +![detail-flow](images/2022-01-27-02.drawio.png) ## 最终效果 diff --git a/docs/images/2021-01-02-01.drawio.png b/docs/images/2021-01-02-01.drawio.png new file mode 100644 index 0000000..0a053e7 Binary files /dev/null and b/docs/images/2021-01-02-01.drawio.png differ diff --git a/docs/images/2021-01-02-01.png b/docs/images/2021-01-02-01.png deleted file mode 100644 index 3827c62..0000000 Binary files a/docs/images/2021-01-02-01.png and /dev/null differ diff --git a/docs/images/2022-01-27-01.drawio.png b/docs/images/2022-01-27-01.drawio.png new file mode 100644 index 0000000..77209b3 Binary files /dev/null and b/docs/images/2022-01-27-01.drawio.png differ diff --git a/docs/images/2022-01-27-01.png b/docs/images/2022-01-27-01.png deleted file mode 100644 index bff028c..0000000 Binary files a/docs/images/2022-01-27-01.png and /dev/null differ diff --git a/docs/images/2022-01-27-02.drawio.png b/docs/images/2022-01-27-02.drawio.png new file mode 100644 index 0000000..9eea619 Binary files /dev/null and b/docs/images/2022-01-27-02.drawio.png differ diff --git a/docs/images/2022-01-27-02.png b/docs/images/2022-01-27-02.png deleted file mode 100644 index 625eecc..0000000 Binary files a/docs/images/2022-01-27-02.png and /dev/null differ diff --git a/docs/images/illustration.drawio.svg b/docs/images/illustration.drawio.svg deleted file mode 100644 index ff40e42..0000000 --- a/docs/images/illustration.drawio.svg +++ /dev/null @@ -1,715 +0,0 @@ - - - - - - - - - - - - - - -
-
-
- A -
-
-
-
- - A - -
-
- - - - -
-
-
- B2 -
-
-
-
- - B2 - -
-
- - - - -
-
-
- B1 -
-
-
-
- - B1 - -
-
- - - - - -
-
-
- trigger -
-
-
-
- - trigger - -
-
- - - - - - - - -
-
-
- A -
-
-
-
- - A - -
-
- - - - -
-
-
- B2 -
-
-
-
- - B2 - -
-
- - - - - - -
-
-
- B1 -
-
-
-
- - B1 - -
-
- - - - - -
-
-
- trigger -
-
-
-
- - trigger - -
-
- - - - - - - - -
-
-
- A -
-
-
-
- - A - -
-
- - - - - - -
-
-
- B2 -
-
-
-
- - B2 - -
-
- - - - -
-
-
- B1 -
-
-
-
- - B1 - -
-
- - - - - -
-
-
- trigger -
-
-
-
- - trigger - -
-
- - - - -
-
-
- (a) -
-
-
-
- - (a) - -
-
- - - - -
-
-
- (b) -
-
-
-
- - (b) - -
-
- - - - -
-
-
- (c) -
-
-
-
- - (c) - -
-
- - - - - - - - -
-
-
- get version number -
-
-
-
- - get version number - -
-
- - - - - - -
-
-
- trigger B1 -
-
-
-
- - trigger B1 - -
-
- - - - - - -
-
-
- trigger B2 -
-
-
-
- - trigger B2 - -
-
- - - - - - -
-
-
- trigger A -
-
-
-
- - trigger A - -
-
- - - - - - -
-
-
- build -
-
-
-
- - build - -
-
- - - - -
-
-
- deploy -
-
-
-
- - deploy - -
-
- - - - - - -
-
-
- trigger A -
-
-
-
- - trigger A - -
-
- - - - - - -
-
-
- build -
-
-
-
- - build - -
-
- - - - -
-
-
- deploy -
-
-
-
- - deploy - -
-
- - - - -
-
-
- project: A -
-
-
-
- - project: A - -
-
- - - - -
-
-
- project: B1 -
-
-
-
- - project: B1 - -
-
- - - - -
-
-
- project: B2 -
-
-
-
- - project: B2 - -
-
- - - - - - -
-
-
- commit from -
- A or B1 -
-
-
-
- - commit from... - -
-
- - - - - - -
-
-
- commit from -
- A or B2 -
-
-
-
- - commit from... - -
-
- - - - -
-
-
- Yes -
-
-
-
- - Yes - -
-
- - - - -
-
-
- Yes -
-
-
-
- - Yes - -
-
- - - - - - -
-
-
- commit from A -
-
-
-
- - commit from A - -
-
- - - - - - -
-
-
- commit from B1 -
-
-
-
- - commit from B1 - -
-
- - - - - - -
-
-
- commit from B2 -
-
-
-
- - commit from B2 - -
-
- - - - - - -
-
-
- branch==release -
-
-
-
- - branch==release - -
-
- - - - - - -
-
-
- branch==release -
-
-
-
- - branch==release - -
-
- - - - -
-
-
- Yes -
-
-
-
- - Yes - -
-
- - - - -
-
-
- Yes -
-
-
-
- - Yes - -
-
-
- - - - - Viewer does not support full SVG 1.1 - - - -
\ No newline at end of file