Photoshop 具有打开 PDF 文档的选项,称为Photoshop.PDFOpenOptions
您需要 win32com 来发送 Photoshop 应用程序。请参阅下面的示例代码
import win32com.client
import os, glob
folderin = r'D:\in'
if (__name__ == '__main__'):
psApp = win32com.client.Dispatch('Photoshop.Application')
for infile in glob.glob(os.path.join(folderin, '*.pdf')):
options = win32com.client.Dispatch('Photoshop.PDFOpenOptions')
options.CropPage = 0 # BoundingBox
options.Resolution = 300 # Pixels
options.Mode = 1 # Grayscale
options.BitsPerChannel = 8 # 8 bits per channel
options.AntiAlias = True
options.ConstrainProportions = True #Deprecated for Adobe Photoshop CS3
doc = psApp.Open(infile, options)
doc.flatten
doc.Trim(1)
doc.Close(2)
psApp.Quit()