jwdj / EasyABC

EasyABC
GNU General Public License v2.0
87 stars 36 forks source link

PDF export do not work in Mac OS 14 #92

Closed urtow closed 5 months ago

urtow commented 5 months ago

Easy ABC version: 1.3.8.1 Mac OS version: 14.4.1

Can't export ABC file to PDF. Because /usr/bin/pstopdf removed from this macOS version.

It can be replaced with ps2pdf from Ghostscript package (brew install ghostscript) but ps2pdf have different cli options:

`AbcToPs /Applications/EasyABC.app/Contents/Resources/bin/abcm2ps - -O /Users/urtow/Library/Application Support/EasyABC/cache/temp.ps abcm2ps-8.14.11 (2020-12-05) File stdin Output written on /Users/urtow/Library/Application Support/EasyABC/cache/temp.ps (1 page, 1 title, 20065 bytes)

AbcToPDF /opt/homebrew/bin/ps2pdf /Users/urtow/Library/Application Support/EasyABC/cache/temp.ps -o /Users/urtow/Library/Application Support/EasyABC/cache/temp.pdf Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]`

And can't export

bomm commented 5 months ago

To check if the different command line syntax is the only problem, and if yes, to work around the problem you can use a shell script.

AbcToPDF /opt/homebrew/bin/ps2pdf /Users/urtow/Library/Application Support/EasyABC/cache/temp.ps -o /Users/urtow/Library/Application Support/EasyABC/cache/temp.pdf

Apparently, EasyABC uses the syntax /path/to/command /path/to/inputfile.ps -o /path/to/outputfile.pdf

Usage: ps2pdfwr [options...] (input.[e]ps|-) [output.pdf|-]

And ps2pdfwr wants to have /path/to/command /path/to/inputfile.ps /path/to/outputfile.pdf without the -o.

You could create a shell script, e.g. /path/of/your/choice/pstopdf-wrapper with the following contents

#!/bin/sh

# we expect 3 arguments and the second one should be "-o"
if [ $# != 3 ] || [ "$2" != "-o" ]
then
    echo "usage: $0 inputfile -o outputfile" >&2
    exit 1
fi
/opt/homebrew/bin/ps2pdf "$1" "$3"

Don't forget to mark the script file as executable: chmod a+x /path/of/your/choice/pstopdf-wrapper

(Not fully tested. I don't have a Mac, I'm using Linux and only checked that the script would call the correct command.)

urtow commented 5 months ago

Shell script does not work, i tried it

bomm commented 5 months ago

The problem description "does not work" is not helpful for analyzing the problem. Does it result in an error message? Then, please, copy&paste the error message. To see what line of the script prints the output, you can add a line set -x after the first one to get the executed commands printed:

#!/bin/sh
set -x

# we expect 3 arguments and the second one should be "-o"
if [ $# != 3 ] || [ "$2" != "-o" ]
then
    echo "usage: $0 inputfile -o outputfile" >&2
    exit 1
fi
/opt/homebrew/bin/ps2pdf "$1" "$3"

When I run the script (named foo), I get this output

$ ./foo bar/in.ps -o /baz/out.pdf
+ '[' 3 '!=' 3 ']'
+ '[' -o '!=' -o ']'
+ /opt/homebrew/bin/ps2pdf bar/in.ps /baz/out.pdf
./foo: line 10: /opt/homebrew/bin/ps2pdf: No such file or directory

(The error message in my example is expected because the program does not exist.)

urtow commented 5 months ago

My fail - script work fine, thank you.