请选择 进入手机版 | 继续访问电脑版

 找回密码
 立即注册
搜索
热搜: Excel discuz
查看: 1721|回复: 0

[项目代码] png图片批量转PDF

[复制链接]

482

主题

7万

元宝

75万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
750844
发表于 2022-3-23 14:15:02 | 显示全部楼层 |阅读模式
  1. import os
  2. import img2pdf
  3. def pngtopdf(path):
  4.     name = path + '.pdf'
  5.     with open(name, "wb") as f:
  6.         f.write(img2pdf.convert([os.path.join(path, file) for file in os.listdir(path) if file.endswith(".png")]))
  7. url = input('请输入文件夹地址:')
  8. A = os.listdir(url)
  9. for i in A:
  10.     pngtopdf(url+'\\'+i)
  11.     print(url+'\\'+i,'已经合成完毕')
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|五花八门论坛 ( 豫ICP备15031300号-3 )

GMT+8, 2024-3-29 13:14 , Processed in 0.099363 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表