Skip to content

file-access errors on ghostscript >= 9.50 #17

@stuart-little

Description

@stuart-little

For newer gs versions every run of pdf2archive results in this error being thrown right at the top of the output:

GPL Ghostscript 9.54.0: Unrecoverable error, exit code 1

After some investigation, I tracked it down to a file-access error related to the "safe" mode that is the default in gs versions 9.50 and higher.

The following patch fixes it (it's literally a one-line change). I'd be happy to make that into a PR if you think it useful.

Patch:

Date:   Sat Jun 12 13:47:26 2021 -0400

    add '-dNOSAFER' option to eliminate gs file-access error

diff --git a/pdf2archive b/pdf2archive
index bac84be..e808079 100755
--- a/pdf2archive
+++ b/pdf2archive
@@ -249,7 +249,7 @@ quit
 #     use 'LC_CTYPE=C && LANG=C && echo "$METADUMP" ...' in the
 #     variable assignments; however, this produces bad PDF files.
 #
-METADUMP=$(gs -dNODISPLAY -q -sFile="$INPUT" $INFOTMPFILE | iconv -f utf-8 -t utf-8 -c)
+METADUMP=$(gs -dNOSAFER -dNODISPLAY -q -sFile="$INPUT" $INFOTMPFILE | iconv -f utf-8 -t utf-8 -c)
 [ -z ${PDFTITLE+x} ] && PDFTITLE=$(echo "$METADUMP" | grep "__knowninfoTitle: " | sed "s/^__knowninfoTitle: //g")
 [ -z ${PDFAUTHOR+x} ] && PDFAUTHOR=$(echo "$METADUMP" | grep "__knowninfoAuthor: " | sed "s/^__knowninfoAuthor: //g")
 [ -z ${PDFSUBJECT+x} ] && PDFSUBJECT=$(echo "$METADUMP" | grep "__knowninfoSubject: " | sed "s/^__knowninfoSubject: //g")

Metadata

Metadata

Assignees

Labels

bugghostscriptThe bug is caused by Ghostscript, not directly by pdf2archive itself.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions