hello I have many pdf files and I eant to convert to .eps using python.
I have find some codes but don't work for me that codes execute without some error but I don't take some .eps file .
any idea ?
I have python 2.7.13
code 1 :
from glob import *
from os import system
fileList = glob('*.pdf')
for f in fileList:
system('pdftops -eps {0}'.format(f))
code 2 :
import os, re, sys
dirList = os.listdir( '.' )
try:
os.mkdir( 'EpsFigs' )
except:
pass
for f in dirList:
m = re.match('([\w\-]+).(|jpg|jp2|png|pdf|)$',f)
if m:
cmd = 'convert %s EpsFigs/%s.eps'%( f, m.group(1) )
os.system(cmd)
Use linux command pdf2ps
to convert pdf to eps.
pdf2ps [ options ] input.pdf [output.ps]
For example,
pdf2ps input.pdf output.eps
If you really want to use python, you can call the above command with subprocess.call
:
from subprocess import call
call(["pdf2ps", "input.pdf", "output.eps"])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.