Not logged in. Log in with Twitter

Sumatra PDF Reader forum

Small, fast, free PDF, EPUB, MOBI, CHM, DJVU, CBR, CBZ reader for Windows

Portable build with GhostScript also portable included

I wish portable Sumatra build wich can handle portable installation of GhostScript in the Sumatra's folder. so: I can copy GhostScr (some files on it- maybe all files) into Sumatra folder and have fully-portable Sumatra which can view PS/EPS.

Is possible?
Alextp on March 25, 2012
SumatraPDF looks for GhostScript either through a Registry key or the environment's PATH. For portable builds, you'll want the second option, i.e. just add the path to your (portable) GhostScript installation to the PATH variable before running SumatraPDF - which you could do e.g. through a batch file:

set PATH=path\to\ghostscript;%PATH%
SumatraPDF.exe path\to\file.ps

Or more generally:

set PATH=%~dp0gs\bin;%PATH%
%~dp0SumatraPDF.exe %1

which assumes that the batch file resides in the same folder as SumatraPDF.exe and that GhostScript is in the "gs" subfolder. Then run the file as

SumatraPS.bat path\to\file.ps
zeniko on March 25, 2012
How does SumatraPDF call ghostscript?
does it call gswin32.exe, gswin32c.exe or does it use the dll gsdll32.dll?
if it uses gswin32.exe a simple solution would be to make a bat file called gswin32.bat in sumatra's dir (I believe the current dir is in the path on win systems) and edit the bat to redirect to where the portable gswin32 is.
for example if you had ghostscript in a subflder called gs in sumatra's folder the bat would have a single line like this:

gs\bin\gswin32.exe %1 %2 %3 %4

I've used this little trick to run mplayer. I have a bat file called mplayer.bat in my path and it has only a single line: "C:\Program Files\Media Players\mplayer\mplayer.exe" %1 %2 %3 %4
user on March 25, 2012
user: SumatraPDF calls gswin32c.exe by its full path, so the file gswin32c.exe itself has to be present in one of the directories listed in %PATH% (and note that SumatraPDF.exe's directory most likely isn't listed there anyway).
zeniko on March 25, 2012
Zeniko: is it possible later to integrate GS's code into Sumatra? So i put GS install to null.
Alexey on March 26, 2012
It would certainly be possible to integrate GhostScript further into SumatraPDF, but we're just as certainly not going to do it (among others because GhostScript alone is much larger than the whole of SumatraPDF and because using an existing GhostScript installation from SumatraPDF is fairly trivial).
zeniko on March 26, 2012
would it be possible for future versions to set the path to ghostscript in the preference file sumatrapdfprefs.dat and the path to be relative not absolute?
That would solve the portable issue Alex has.
ilija on March 31, 2012
ilija: How is modifying sumatrapdfprefs.dat any easier than creating a batch file as described in my first comment?
zeniko on March 31, 2012
Alex has a rather nice freeware app that uses tc lister plugins, one of those embeds sumatrapdf in his viewer, his app is portable and I think he'd like to be able to add ps support via sumatrapdf which is portable and ghostscript which isn't, his app calls a dll that embeds sumatrapdf.exe, that's why he prefers a build that doesn't require a bat file, maybe the dll could be modified to set the path to ghostscript before calling sumatra it's gpl'ed too, me I don't use portable ghoscscript so it's not a problem for me, it was just an idea.
ilija on March 31, 2012
Well, since his app is not released under GPL he's treading a very thin legal line.

He certainly violates the spirit of the GPL license and it's possible that the technical work-around of GPL restrictions would be found to violate the license as well.

Either way, I have no desire to help people abuse our code in such ways.
Krzysztof Kowalczyk on March 31, 2012
actually most of his app is gpl'ed (the base delphi vcl components used by his app are gpl'd and can be downloaded from his home page) and about the thin line yes I remember the k-mplayer/gabest issue a few years ago (kmplayer included gpl'd dll's from gabest and it was a completely closed source app the same goes for zoomplayer).
ilija on March 31, 2012
I like to make a portable build of my open source MC Musiceditor (GPLv2, www.mcmusiceditor.com), avoiding the batch option of Zeniko (which is ok but could run into administrator issues).
.
Idea: the file gswin32c.exe is found in subfolder 'gs/bin' in the working directory of SumatraPDF. I wonder if this could work (my C++ activity is more than 20 years ago): the following code in PsEngine.cpp before line 47 (that says: // return the path to the newest installation):
.
..........................................................
char buff[PATH_MAX];
getcwd( buff, PATH_MAX );
std::string cwd( buff );

std::string gswinPathExe;
string gswinPathExe = cwd + "/gs/bin/";

ScopedMem<TCHAR> exe(path::gswinPathExe, _T("gswin32c.exe")));
if (file::Exists(exe))
return exe.StealData()

..........................................................
Thanks in advance.

Reinier
Reinier Maliepaard on October 23, 2012
Reinier: From looking at your source code, it seems that you're invoking SumatraPDF.exe yourself for viewing the Postscript file. In that case, you should be able to programatically add Ghostscript to the %PATH% variable just for your process and the processes invoked from it without having to either use a batch file nor modify SumatraPDF's sources.

(BTW: Per the GPL, you shouldn't just include the modifications you made to SumatraPDF's source code but the entire source.)
zeniko on October 23, 2012

Powered by fofou, created by Krzysztof Kowalczyk