Created
March 21, 2013 11:10
-
-
Save mjul/5212271 to your computer and use it in GitHub Desktop.
Convert the Visio drawings in the current directory to PDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.