matteosecli / matteosecli/pdf2archive

file-access errors on ghostscript >= 9.50

Open
#17 5 comments 1 reaction 1 assignee View on GitHub

@stuart-little is already working on this.

Since Jun 24, 2021.

bug ghostscript
Dominant language
Shell
Stars
87
Forks
19
PR merge metrics
No merged PRs in 30d

Description

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](https://ghostscript.com/doc/9.50/Use.htm#Safer) 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")
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.