Ask coding questions

← Back to all posts
Converting multiple SVG files to PDF in Python?
georgereynolds (0)

I have a python 3 script which uses 'convert' (a unix/linux utliity) to convert multiple SVG files to a single PDF file. Works very well from my Windows 10 box using the Ubuntu Linux command line, but not in

Any alternatives or tips ?

I've seen python SVG convert utilities but not sure if any work with multiple SVG files to one PDF file

def convert_to_pdf():
    print("Tidying files...")
    print("Converting to PDF (can take a while)...")
    cmd = 'convert '+str(directory_in_str)+'/*.svg '+str(directory_in_str)+'/'+str(magid)+"_"+str(issueid)+'.pdf'
    returned_value =, shell=True)  # returns the exit code in unix
    print('PDF conversion process ended with value: ', returned_value)
    if returned_value == 0:
        print('PDF conversion completed OK')
        print ('PDF conversion failed?')
leooel (0)

Hi, I have a working draft, I convert SVG files into one PDF.

PaoloAmoroso (67)

The convert program isn't available in the shell, so I'm afraid your script can't work on the platform as it relies on that specific program.

georgereynolds (0)


Yeah I appreciate that. However, is there anything else I can use natively in python to achieve the same objective?

PaoloAmoroso (67)

@georgereynolds there are good image and file conversion libraries in PyPI but I'm afraid I haven't tried any yet.