【pdf文件生成】如何将盖章的文件生成PDF文件

一、提出问题

在我们的工作中,有时候上级让下级将盖章的文件生成PDF文件通过内部平台发送到上级邮箱,那如何解决呢?是去找一个扫描仪,还是用手机拍图转。用Python基实就能实现。

二、分析问题

现在网上好多的软件都是收费的,转pdf,转word

三、pdf2docx模块的使用

1.安装模块

pip install pdf2docx

2.介绍

pdf2docx 是一个Python模块,可以用来将PDF文件转换成Word文档。它是基于Python的pdfminer和python-docx库开发的,可以在Windows、Linux和Mac系统上运行。

四、案例分析

1.单个文件转pdf

import pdf2docx

pdf2docx.convert(word.docx),

注意:pdf文件不用填加,在原目录自动生成。

2.多个word 转换成pdf

复制代码
import docx2pdf
import os

pdf_path =r"C:\Users\lenovo\Desktop\test\\"
files = []
for file in os.listdir(pdf_path):
    if file.endswith(".docx"):
        files.append(pdf_path+file)
        print(files)
for file in files:
    print(file)
    docx2pdf.convert(str(file))
    file_name=file.split(".")[0]
    print(f"{file_name}转换成功!")
相关推荐
金銀銅鐵14 小时前
用 Tkinter 实现简单的猜数字游戏
后端·python
copyer_xyf14 小时前
Python 模块与包的导入导出
前端·后端·python
ice81303318115 小时前
【Python】Matplotlib折线图绘制
开发语言·python·matplotlib
copyer_xyf15 小时前
Python venv 虚拟环境
前端·后端·python
林爷万福16 小时前
GitHub 开源光谱数据处理项目推荐
python·光纤光谱仪
copyer_xyf16 小时前
Python 如何同时做很多事:进程、线程、协程
前端·后端·python
Full Stack Developme16 小时前
Spring Bean 依赖注入
python·spring·log4j
yuhuofei202116 小时前
【Python入门】Python中的元组tuple
python
清水白石00817 小时前
从菱形继承到 `super()`:彻底理解 Python MRO 与多继承方法查找机制
开发语言·python
CTA终结者18 小时前
期货量化下单前资金怎么核对:天勤 get_account 与可用、权益字段
python·区块链