Created
July 17, 2018 20:10
-
-
Save pbfy0/5e505a75c73e2f48a469dc39f5959168 to your computer and use it in GitHub Desktop.
This file contains 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
$ghostscript = "C:\Program Files\gs\gs9.22\bin\gswin64c.exe" | |
$sumatrapdf = "C:\Program Files\SumatraPDF\SumatraPDF.exe" | |
$filename = $args[0] | |
if($filename.EndsWith("_gs.pdf")) { | |
Start-Process $sumatrapdf -ArgumentList $filename | |
exit | |
} | |
$nfn = $filename -replace "\.pdf$","_gs.pdf" | |
if(Test-Path $nfn -PathType leaf) { | |
$orig_mt = (Get-Item $filename).LastWriteTime | |
$new_mt = (Get-Item $nfn).LastWriteTime | |
if($new_mt -ge $orig_mt) { | |
Start-Process $sumatrapdf -ArgumentList $nfn | |
exit | |
} | |
} | |
& $ghostscript -q -sDEVICE=pdfwrite -o $nfn $filename | |
Start-Process $sumatrapdf -ArgumentList $nfn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment