import os
import pdfplumber
# localName = quicker.context.GetVarValue('firstFile');
def run(path):
pt = 72/25.4
with pdfplumber.open(path) as pdf:
page_1 = pdf.pages[0]
return str(round(page_1.height/pt))+'x'+str(round(page_1.width/pt))+'-'+str(len(pdf.pages))
def savetxt(path,value):
# 打开文件
fd = os.open( path,os.O_RDWR|os.O_CREAT )
os.write(fd, value.encode())
os.close( fd )
path = r'C:\Users\Administrator\Desktop\202208231343 PO#283866 5004634_printing@F 128g 铜 上光 5310.pdf'
name = os.path.basename(path)[0:-4]
parent = os.path.dirname(path)
p = "C:/Users/Administrator/Desktop/text.txt"
# savetxt(parent+'/'+name+'.txt',run(path))
os.rename(path,parent+'/'+'【'+run(path)+'】'+name+'.pdf')
python 获取pdf 尺寸与页数
最新推荐文章于 2024-07-06 03:10:01 发布