Giter VIP home page Giter VIP logo

Comments (8)

GitHubRulesOK avatar GitHubRulesOK commented on July 19, 2024 1

@sergsako

3.5.2 portable will still work with GS 10.03 (earlier versions may not)
image

You can add your own command depending on GS version and location. The && pause is to let you check for error messages if it works reliably remove it

ExternalViewers [
	[
		CommandLine = c:\windows\system32\cmd.exe /r " "C:\Program Files\gs\gs10.03.0\bin\gswin32c.exe" -sDEVICE=pdfwrite -o "%1.pdf" -f "%1" && pause "
		Name = Convert &To PDF
		Filter = *.ps;*.eps
	]
]

image

so where is your "path/GSwin##c.exe" and what version

from sumatrapdf.

sergsako avatar sergsako commented on July 19, 2024 1

@GitHubRulesOK
Thank you. PS and EPS files are very rare formats last years, and I understand that there is no reason for SumatraPDF to depend on external Ghostscript. As I use PS/EPS only a few times a year, it will be more convenient to keep separately a copy of portable 3.4.6 for conversion EPS -> PDF in a habitual way.

from sumatrapdf.

GitHubRulesOK avatar GitHubRulesOK commented on July 19, 2024 1

You dont need to keep a separate version I use a shortcut to convert PS 2 PDF and as SumatraPDF is installed Default PDF Viewer (all being well) it opens a new pdf tab almost instantly ALT + F + T
image

image

ExternalViewers [
	[
		CommandLine = c:\windows\system32\cmd.exe /r " "C:\Program Files\gs\gs10.03.0\bin\gswin32c.exe" -sDEVICE=pdfwrite -o "%1.pdf" -f "%1" && "%1.pdf" "
		Name = Convert &To PDF
		Filter = *.ps;*.eps
	]

from sumatrapdf.

GitHubRulesOK avatar GitHubRulesOK commented on July 19, 2024 1

@sergsako
The old version did basically the same running command line "behind the scenes"
but will have taken page size into account, so as not to use the default of A4.

However NOTE that in my PS test the page size was its own size unchanged, perhaps its an EPS thing ?
image

The problems stemmed from GS changes in command line syntax between versions
especially between 9 and 10 as they improved security and removed or added methods.

Yes 3.4.6 works with current 10.0 but no assurance it would work with say future 11 as PS support is frequently changing !

Thus my favourite legacy SumatraPDF 3.1.2 XP will not work with GS 10.# or later 9.#'s

The extraction of page size for passing on was very much down to SumatraPDF code but the command passed to GS was very legacy method -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile= are no longer needed in latest syntax.

// try to help Ghostscript determine the intended page size
    AutoFreeWstr psSetup;
    Rect page = ExtractDSCPageSize(path);
    if (!page.IsEmpty()) {
        psSetup = str::Format(L" << /PageSize [%i %i] >> setpagedevice", page.dx, page.dy);
        AutoFreeWstr psSetup = str::Format(L" << /PageSize [%i %i] >> setpagedevice", page.dx, page.dy);
        cmdLine = str::Format(
            L"\"%s\" -q -dSAFER -dNOPAUSE -dBATCH -dEPSCrop -sOutputFile=\"%s\" -sDEVICE=pdfwrite -c "
            L"\".setpdfwrite%s\" -f \"%s\"",
            gswin32c.Get(), tmpFile.Get(), psSetup.Get(), shortPath.Get());

Today that could be simpler but would still need to query the displayed page sizes.

So for your desire to query page size yes 3.4.6 will be easier

from sumatrapdf.

GitHubRulesOK avatar GitHubRulesOK commented on July 19, 2024

@sergsako

Not strictly an issue as it was intentionally removed, the ability is native to GS anyway so no need for 3rd party apps like Gimp or IrfanView or other image apps to add a GUI for multiple files as you can only save one at a time and Artifex caused a lot of apps to encounter problems when they changed some switches at different versions so now quite a lot of profiles would be needed to cover all circumstances.

from sumatrapdf.

sergsako avatar sergsako commented on July 19, 2024

Sorry, if it was made intentionally, I have to close this "issue".

from sumatrapdf.

sergsako avatar sergsako commented on July 19, 2024

@GitHubRulesOK
Ok, I have understood and tried the way you proposed. It is, unfortunately, too complicated to people like me, I would better study the command line interface of Ghostscript directly if I could. And your way gives not exactly what I expect from conversion of 3.33x2.15 inch EPS picture to PDF: the resulting PDF is A4 sized page with a small picture printed at the left-bottom corner.
On the contrary, using "Save As PDF" in SumatraPDF 3.4.6 (which is an old version but nevertheless it recognizes the latest Ghostscript 10.03.1 installed and knows its commands) I get the desired 3.33x2.15 inch PDF picture.
All that, however, does not mean that I have a feature request to bring back the PS to PDF conversion. I do understand that very few people need in it.

from sumatrapdf.

GitHubRulesOK avatar GitHubRulesOK commented on July 19, 2024

@kjk I see the core code for PS conversion is still in current code base

    // TODO: before gs 9.54 we would call:
    // Rect page = ExtractDSCPageSize(path);
    // and use that to add "-c ".setpdfwrite << /PageSize [$dx $dy] >> setpagedevice"
    // to cmd-line. In 9.54 .setpdfwrite was removed and using it causes
    // conversion to fail
    // So we removed use of -c .setpdfwrite completely. Not sure if there's an alternative
    // way to do it
    // https://github.com/GravityMedia/Ghostscript/issues/6
    // https://github.com/sumatrapdfreader/sumatrapdf/issues/1923
    TempStr cmdLine = str::FormatTemp(
        "\"%s\" -q -dSAFER -dNOPAUSE -dBATCH -dEPSCrop -sOutputFile=\"%s\" -sDEVICE=pdfwrite "
        "-f \"%s\"",
        gswin32c.Get(), tmpFile, shortPath);

so the current method to run in GS 9.5+ can be simpler than

 "\"%s\" -q -dSAFER -dNOPAUSE -dBATCH -dEPSCrop -sOutputFile=\"%s\" -sDEVICE=pdfwrite "

the newer syntax would be

 "\"%s\" -q -dEPSCrop -o=\"%s\" -sDEVICE=pdfwrite "

the main issue here seems to be how to determine page size by query GS info ?
but that is not a PS file issue as shown here
image

The whole process recommended by Ghostscript is

Ensure BIN\GSWIN32c is on path by include the bin directory if it is not already there
Then call LIB\ps2pdf.bat which does all the work to add the pdf alongside the ps file like this

image

from sumatrapdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.