summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/psviewer
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2020-07-10 13:31:32 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2020-07-10 13:31:32 +0000
commit11ff8420389723e2349ea7b1449a094aa7a919ef (patch)
treed58f703ddb808b3e8cd7798ebd0ae634cbea86a6 /Master/texmf-dist/scripts/psviewer
parent65f9071f1b4b2e183a975afa5548f261bf4e8d84 (diff)
Psviewer script added
git-svn-id: svn://tug.org/texlive/trunk@55797 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/psviewer')
-rw-r--r--Master/texmf-dist/scripts/psviewer/psviewer.vbs65
1 files changed, 65 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/psviewer/psviewer.vbs b/Master/texmf-dist/scripts/psviewer/psviewer.vbs
new file mode 100644
index 00000000000..3df3ca29a53
--- /dev/null
+++ b/Master/texmf-dist/scripts/psviewer/psviewer.vbs
@@ -0,0 +1,65 @@
+' Written by Siep Kroonenberg in 2020 and placed in the Public Domain
+
+option explicit
+On Error Resume next
+
+dim oWsh, oFS, sTmp, oArgs, f, fname, tf, i, msg
+
+set oWsh = wscript.createobject( "wscript.Shell" )
+Set oFS = CreateObject("Scripting.FileSystemObject")
+sTmp=oWsh.ExpandEnvironmentStrings("%Temp%")
+
+Set oArgs = wscript.arguments
+If oArgs.count = 0 Then
+ msg = "Psviewer is a simple script which converts its argument to a " & _
+ " temporary pdf and displays it in the default pdf viewer." _
+ & vbcrlf & vbcrlf & _
+ "Double-clicking an .eps- or .ps file should result in viewing the " & _
+ "converted file. If this does not work, then try right-click and " & _
+ "'Open with', which should give you the option to set psviewer as " & _
+ "default program for .[e]ps files."
+ MsgBox msg, 0, "Psv: no argument"
+ wscript.quit
+End If
+f = oArgs( 0 )
+fname = oFS.getfile( f ).Name
+
+Randomize
+
+' find a name for a new temporary pdf file
+i = 0
+do
+ tf = sTmp & "\" & fname & "-" & Int(100000 * Rnd) & ".pdf"
+ i = i + 1
+ If Not oFS.FileExists( tf ) then
+ Exit do
+ else
+ tf = ""
+ if i >= 500 Then
+ Exit Do
+ End If
+ End If
+Loop
+If tf = "" Then
+ wscript.echo "Cannot create temporary pdf"
+ wscript.quit
+End If
+
+' create temporary pdf
+If LCase( Right( fname, 4 )) = ".eps" Then
+ If oWsh.run( "kpsewhich -format texmfscripts epstopdf.pl", 0, true ) = 0 Then
+ oWsh.run "epstopdf " & oArgs( 0 ) & " " & tf, 0, true
+ Else
+ oWsh.run "gswin32c -q -dNOPAUSE -dBATCH -P- -dSAFER -sDEVICE#pdfwrite -dEPSCrop -sOutputFile#" & tf & " -f " & f, 0, true
+ End if
+Else
+ oWsh.run "gswin32c -q -dNOPAUSE -dBATCH -P- -dSAFER -sDEVICE#pdfwrite -sOutputFile#" & tf & " -f " & f, 0, true
+End If
+
+' open temporary pdf
+If oFS.fileexists(tf) Then
+ oWsh.run( tf )
+Else
+ MsgBox f & " could not be converted," & vbcrlf & _
+ "is probably not valid PostScript", 0, "Error"
+End If \ No newline at end of file