当前位置:   article > 正文

实用代码Python(六)批量PPT转PDF_python ppt转pdf

python ppt转pdf

前言

将批量转化后的PDF融合为一个PDF文件,参考:实用代码Python(二):使用PyPDF2融合多个PDF文件

使用PyPDF2融合多个PDF文件

from PyPDF2 import PdfFileMerger
import os
files = os.listdir()

pdfs = []

for file in files:
	if file[-4:] == ".pdf":
		pdfs.extend([file])


merger = PdfFileMerger()

for pdf in pdfs:
    merger.append(open(pdf, 'rb'))

with open('java.pdf', 'wb') as fout:
    merger.write(fout)
	
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

代码(批量PPT转PDF)

import comtypes.client
import os

def init_powerpoint():
	powerpoint = comtypes.client.CreateObject("Powerpoint.Application")
	powerpoint.Visible = 1
	return powerpoint
 
def ppt_to_pdf(powerpoint, inputFileName, outputFileName, formatType = 32):
	if outputFileName[-3:] != 'pdf'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号