I am trying to install fig2pdf library on my macbook, which uses macOS Catalina. The idea is to convert the fig file created by xfig to pdf with the Latex operations. I downloaded the relevant linux executable files from this link. http://www.few.vu.nl/~wkager/tools.htm . I installed ghostscript and other required dependencies using brew. However, when I try to generate my pdf using the fig file, I get this error.
[error]
fig2pdf: Ghostscript says:
Error: /typecheck in /--.beginpage--
Operand stack:
false --dict:1/1(L)-- --nostringval-- --dict:210/210(ro)(L)-- --dict:1/1(L)-- --dict:0/0(L)-- --dict:210/219(ro)(L)-- 0
Execution stack:
%interp_exit .runexec2 --nostringval-- .beginpage --nostringval-- 2 %stopped_push --nostringval-- .beginpage .beginpage false 1 %stopped_push .runexec2 --nostringval-- .beginpage --nostringval-- 2 %stopped_push --nostringval-- 1938 1 3 %oparray_pop .beginpage .beginpage 1819 7 3 %oparray_pop .beginpage 9
Dictionary stack:
--dict:733/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
However, this same fig file can be converted into pdf using linux without any issue, therefore the fig file is good. Can someone help me with fixing this issue?
The full stack trace is as below.
Najaths-MacBook-Pro:Documents najathakram$ ./fig2pdf figSDR.fig
fig2pdf 2015/08/01 by Wouter Kager
fig2pdf: processing file figSDR.fig
fig2pdf: warning, the file figSDR.pdf exists!
fig2pdf: should I overwrite it (y/n)? y
fig2pdf: figSDR.fig -> figSDR.pdf GPL Ghostscript 9.50: Unrecoverable error, exit code 1
expr: not a decimal number: 'in'
expr: not a decimal number: '--file--'
expr: not a decimal number: 'Error:'
expr: not a decimal number: '/invalidfileaccess'
awk: cmd. line:6: x2=int(*1.00375+0.999);
awk: cmd. line:6: ^ syntax error
awk: cmd. line:7: y2=int(*1.00375+0.999);
awk: cmd. line:7: ^ syntax error
awk: cmd. line:2: if ($2>0) $2=0; if ($4<) $4=;
awk: cmd. line:2: ^ syntax error
awk: cmd. line:2: if ($2>0) $2=0; if ($4<) $4=;
awk: cmd. line:2: ^ syntax error
awk: cmd. line:3: if ($3>0) $3=0; if ($5<) $5=;
awk: cmd. line:3: ^ syntax error
awk: cmd. line:3: if ($3>0) $3=0; if ($5<) $5=;
awk: cmd. line:3: ^ syntax error
BASH=/bin/sh
BASH_ARGC=([0]="1")
BASH_ARGV=([0]="figSDR.fig")
BASH_LINENO=([0]="370" [1]="0")
BASH_SOURCE=([0]="./fig2pdf" [1]="./fig2pdf")
BASH_VERSINFO=([0]="3" [1]="2" [2]="57" [3]="1" [4]="release" [5]="x86_64-apple-darwin19")
BASH_VERSION='3.2.57(1)-release'
DIRSTACK=()
DISPLAY=/private/tmp/com.apple.launchd.6ULZu7qFoQ/org.macosforge.xquartz:0
EUID=501
FUNCNAME=([0]="find_bbox" [1]="main")
GROUPS=()
HOME=/Users/najathakram
HOSTNAME=Najaths-MacBook-Pro.local
HOSTTYPE=x86_64
IFS='
'
INFOPATH=/opt/sw/share/info:/opt/sw/info:/usr/share/info
LANG=en_US.UTF-8
LOGNAME=najathakram
MACHTYPE=x86_64-apple-darwin19
MANPATH=/opt/sw/share/man:/opt/local/share/man::/opt/sw/lib/perl5/5.18.4/man
OK=y
OPTERR=1
OPTIND=1
OSTYPE=darwin19
PATH=/opt/sw/lib/perl5/ExtUtils:/opt/sw/bin:/opt/sw/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin
PERL5LIB=/opt/sw/lib/perl5:/opt/sw/lib/perl5/darwin
PIPESTATUS=([0]="0")
POSIXLY_CORRECT=y
PPID=845
PS4='+ '
PWD=/Users/najathakram/Documents
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=2
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.VAaK6drxYp/Listeners
TERM=xterm-256color
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=433
TERM_SESSION_ID=ADCFB5E9-5036-477F-995C-6D3ED0F20754
TMPDIR=/var/folders/7l/blk67nn13t97ym5ptgqm70lc0000gn/T/
UID=501
USER=najathakram
XAPPLRESDIR=/opt/sw/etc/app-defaults/
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
_=Ghostscript
base=figSDR
class='\documentclass{article}'
csub=
debug=n
dx=
dy=
field=color,
file=fig2pdf-OyfkIT.pdf
force=n
fsub=
gsopts='-q -dSAFER -dNOPAUSE -dBATCH'
ht=
j=fig2pdf-OyfkIT.pdf
level=1.3
log='%%BoundingBox: 0 0 0 0
%%HiResBoundingBox: 0.000000 0.000000 0.000000 0.000000'
mode=pdf
mpsub='[1 0 0 -1 0 0]'
optionkey='?'
options=
packages='\usepackage{color}\usepackage{graphicx}'
preamble=
program=fig2pdf
scale=1.00375
setspecial=0
specialtext=1
subfield=color
tmp=fig2pdf-OyfkIT
tmpfiles='fig2pdf-OyfkIT.tex fig2pdf-OyfkIT.aux fig2pdf-OyfkIT.log fig2pdf-OyfkIT.eps fig2pdf-OyfkIT.pdf'
version=2015/08/01
wd=
x1=0
x2=
y1=0
y2=
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
[error]
fig2pdf: Ghostscript says:
Error: /typecheck in /--.beginpage--
Operand stack:
false --dict:1/1(L)-- --nostringval-- --dict:210/210(ro)(L)-- --dict:1/1(L)-- --dict:0/0(L)-- --dict:210/219(ro)(L)-- 0
Execution stack:
%interp_exit .runexec2 --nostringval-- .beginpage --nostringval-- 2 %stopped_push --nostringval-- .beginpage .beginpage false 1 %stopped_push .runexec2 --nostringval-- .beginpage --nostringval-- 2 %stopped_push --nostringval-- 1938 1 3 %oparray_pop .beginpage .beginpage 1819 7 3 %oparray_pop .beginpage 9
Dictionary stack:
--dict:733/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Ghostscript doesn't accept a 'fig' file as input, it only accepts PostScript or PDF, so whatever 'fig2pdf' is doing it must be creating (I assume) a PostScript file before turning that into a PDF file. Or, alternatively, running a PostScript program which consumes a 'fig' file and uses it to generate marking operations in PostScript.
There are two backchannel traces in your question; one you've only supplied a partial back channel for and says 'typecheck in /--.beginpage', but more interesting is the second one which has an invalidfileaccess error.
Since the release of 9.50, Ghostscript starts up in SAFER mode, this means that the PostScript file operators are only able to access files and devices which have been specifically permitted. Permission is all from the command line, either implicitly (such as specifying an input file, or an output file) or explicitly by using the relevant switch (such as --permit-file-reading=....).
I would guess that the script runs a PostScript program which reads the fig file from disk, and that is failing because you have not specifically granted permission for the file to be read. You need to update the script to add that permission.
The documentation regarding file permissions can be found online here (scroll down a little to find SAFER) and should be in the ghostpdl/doc directory in your Ghostscript installation.