Convert SVG files to PDF or PNG with InkScape and PowerShell

InkScape is a very useful tool to create visuals and documents. A boring task with InkScape is the exportation to PNG or PDF. A simple PowerShell script can help quickly export evcey SVG from a directory.

Demonstration :

SVG to PNG

Download

param ($dpi = 90)
set-alias inkscape "C:\Program Files\Inkscape\inkscape.exe"
Get-ChildItem -Filter *.svg | % {
    $src = $_.FullName
    $dst = $src -replace "\.svg$", ".png"
    "inkscape -f $($src) -e $($dst) -d $($dpi)"
    inkscape -f "$($src)" -e "$($dst)" -d "$($dpi)"
}
Write-Host "done !"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

SVG vers PDF

Nota bene : the option -T forces fonts to be converted to vectorial so there is no problem with exotic fonts.

Download

param()
set-alias inkscape "C:\Program Files (x86)\Inkscape\inkscape.exe"
Get-ChildItem -Filter *.svg | % {
    $src = $_.FullName
    $dst = $src -replace "\.svg$", ".pdf"
    "inkscape -f $($src) -A $($dst) -T"
    inkscape -f "$($src)" -A "$($dst)" -T
}
Write-Host "done !"
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.