Stücke
Stücke

Reputation: 993

Batch conversion of PDF to EPS via command line

I am trying to convert some figures from *.pdf to *.eps via Inkscape and Python. I resorted to the Inkscape Manual and Inkscape Wiki and came up with the code below. However when I run the script, no output is written into the working directory.

import os 
import subprocess

# Change to working directory
os.chdir("C:/Users/Username/Figures")

# Iterate over all PDF figures
for figure in [i for i in os.listdir() if i[-4:]=='.pdf']:

    subprocess.run([
        "C:/Program Files/Inkscape/inkscape.exe",
        figure, # Input figure
        f"--export-filename={figure[:-4]}.eps", # Output figure
        "--batch-process"
        ])

There is also a similar question on Stackoverflow. However, if I replace *.emf with *.eps in the answer the files cannot be read by LaTeX.


Update: Inkscape version 0.92.4 (5da689c313, 2019-01-14)

Upvotes: 0

Views: 409

Answers (0)

Related Questions