Skip to content

Instantly share code, notes, and snippets.

@mjul
Created March 21, 2013 11:10
Show Gist options
  • Save mjul/5212271 to your computer and use it in GitHub Desktop.
Save mjul/5212271 to your computer and use it in GitHub Desktop.
Convert the Visio drawings in the current directory to PDF
# Convert Visio (2013) documents to PDF
$drawings = Get-ChildItem -Filter "*.vsdx"
Write-Host "Converting Visio documents to PDF..." -ForegroundColor Cyan
try
{
$visio = New-Object -ComObject Visio.Application
$visio.Visible = $true
foreach ($drawing in $drawings)
{
$pdfname = [IO.Path]::ChangeExtension($drawing.FullName, '.pdf')
Write-Host "Converting:" $drawing.FullName "to" $pdfname
$document = $visio.Documents.Open($drawing.FullName)
# Export all pages to PDF, see constants here http://msdn.microsoft.com/en-us/library/office/ff766893.aspx
$document.ExportAsFixedFormat(1, $pdfname, 1, 0)
}
}
catch
{
Write-Error $_
}
finally
{
if ($visio)
{
$visio.Quit()
}
}
@wadelyman
Copy link

Trying to understand where the output directory is specified. I ran this and it appeared to be working but I couldn’t find the output files. Apologies, I’m a bit new.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment