Python—problems encountered, various problems encountered when using PyPDF2 to convert pdf.

1. An error message appears. (PyPDF2. errors. DeprecationError)

An abnormal problem occurred during PDF conversion, and an error was reported directly, prompting to delete this method.
PyPDF2.errors.DeprecationError: PdfFileMerger is deprecated and was removed in PyPDF2 3.0.0. Use PdfMerger instead.
原因:PyPDF2 3.0.0 删除了 PdfFileMerger 方法。
解决方法:将所有的 PdfFileMerger 改成 PdfMerger。

2. When converting svg to pdf, there is a problem with the box, and the font is garbled.

insert image description here

原因:系统中没有svg中设置的字体格式。
(在CentOS7或alibaba cloud linux 3系统的报表中,发现有中文乱码和中文字体不整齐(重叠)的情况,首先考虑的就是操作系统是否有中文字体。)
解决方法:添加安装字体,先找到字体格式进行下载。

The problem of installing Chinese fonts in Linux.

第一步:查看字体列表
fc-list

第二步:安装默认字体库
yum install fontconfig

第三步:安装ttmkfdir
yum install ttmkfdir

第四步:创建中文字体存放目录

命令:mkdir /usr/share/fonts/chinese

第五步:将下载到字体上传到Linux系统中
.ttc 的字体复制到/usr/share/fonts/chinese目录中

第六步:设置目录权限

命令:chmod -R 755 /usr/share/fonts/chinese

第七步,重启服务器。

命令:init 6

upload font

insert image description here

Guess you like

Origin blog.csdn.net/weixin_45195493/article/details/128545244