From 11ff8420389723e2349ea7b1449a094aa7a919ef Mon Sep 17 00:00:00 2001 From: Siep Kroonenberg Date: Fri, 10 Jul 2020 13:31:32 +0000 Subject: Psviewer script added git-svn-id: svn://tug.org/texlive/trunk@55797 c570f23f-e606-0410-a88d-b1316a301751 --- Master/bin/win32/psviewer.exe | Bin 0 -> 17920 bytes Master/texmf-dist/doc/psviewer/psviewer.README | 7 ++ Master/texmf-dist/doc/psviewer/psviewer.ico | Bin 0 -> 3774 bytes Master/texmf-dist/doc/psviewer/psviewer.svg | 137 ++++++++++++++++++++++++ Master/texmf-dist/scripts/psviewer/psviewer.vbs | 65 +++++++++++ 5 files changed, 209 insertions(+) create mode 100755 Master/bin/win32/psviewer.exe create mode 100644 Master/texmf-dist/doc/psviewer/psviewer.README create mode 100644 Master/texmf-dist/doc/psviewer/psviewer.ico create mode 100644 Master/texmf-dist/doc/psviewer/psviewer.svg create mode 100644 Master/texmf-dist/scripts/psviewer/psviewer.vbs diff --git a/Master/bin/win32/psviewer.exe b/Master/bin/win32/psviewer.exe new file mode 100755 index 00000000000..b2574a95313 Binary files /dev/null and b/Master/bin/win32/psviewer.exe differ diff --git a/Master/texmf-dist/doc/psviewer/psviewer.README b/Master/texmf-dist/doc/psviewer/psviewer.README new file mode 100644 index 00000000000..2ddb3d8135f --- /dev/null +++ b/Master/texmf-dist/doc/psviewer/psviewer.README @@ -0,0 +1,7 @@ +Psviewer is a simple script which converts its argument to a +temporary pdf and displays it in the default pdf viewer. + +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. diff --git a/Master/texmf-dist/doc/psviewer/psviewer.ico b/Master/texmf-dist/doc/psviewer/psviewer.ico new file mode 100644 index 00000000000..1032ddca666 Binary files /dev/null and b/Master/texmf-dist/doc/psviewer/psviewer.ico differ diff --git a/Master/texmf-dist/doc/psviewer/psviewer.svg b/Master/texmf-dist/doc/psviewer/psviewer.svg new file mode 100644 index 00000000000..7fc1674f4d6 --- /dev/null +++ b/Master/texmf-dist/doc/psviewer/psviewer.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + 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 -- cgit v1.2.3