pdfsandwich failes after 'convert' error
Brought to you by:
tobias-elze
Pdfsandwich is failing on my system (MacOS Mojave) on all PDF jobs (single or multi-page jobs). I originally thought this might be linked to Bug #22 or #25 but it doesn't appear to be the case. Here is the full output of the verbose command:
pdfsandwich -verbose mypdf.pdf pdfsandwich version 0.1.6 Checking for convert: convert -version Version: ImageMagick 6.9.9-40 Q16 x86_64 2019-06-25 http://www.imagemagick.org Copyright: © 1999-2018 ImageMagick Studio LLC License: http://www.imagemagick.org/script/license.php Features: Cipher DPC Modules Delegates (built-in): bzlib djvu fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms ltdl lzma openexr png ps raw tiff webp x xml zlib Checking for unpaper: unpaper -V 6.1 Checking for tesseract: tesseract -v tesseract 4.0.0 leptonica-1.77.0 libjpeg 9c : libpng 1.6.37 : libtiff 4.0.10 : zlib 1.2.11 : libwebp 1.0.2 : libopenjp2 2.3.1 Found AVX Found SSE Checking for gs: gs -v GPL Ghostscript 9.27 (2019-04-04) Copyright (C) 2018 Artifex Software, Inc. All rights reserved. Checking for pdfinfo: pdfinfo -v pdfinfo version 0.78.0 Copyright 2005-2019 The Poppler Developers - http://poppler.freedesktop.org Copyright 1996-2011 Glyph & Cog, LLC Checking for pdfunite: pdfunite -v pdfunite version 0.78.0 Copyright 2005-2019 The Poppler Developers - http://poppler.freedesktop.org Copyright 1996-2011 Glyph & Cog, LLC Input file: "mypdf.pdf" Output file: "mypdf_ocr.pdf" Number of pages in inputfile: 2 More threads than pages. Using 2 threads instead. Parallel processing with 2 threads started. Processing page order may differ from original page order. Processing page 2. identify -format "%w\n%h\n" "/var/folders/zv/4grr_0152bng1c9jn0zdltsh0000gn/T/pdfsandwich_inputfile68af10.pdf[1]" Processing page 1. identify -format "%w\n%h\n" "/var/folders/zv/4grr_0152bng1c9jn0zdltsh0000gn/T/pdfsandwich_inputfile68af10.pdf[0]" Warning: could not determine page size; defaulting to A4. convert -units PixelsPerInch -type Bilevel -density 300x300 "/var/folders/zv/4grr_0152bng1c9jn0zdltsh0000gn/T/pdfsandwich_inputfile68af10.pdf[1]" /var/folders/zv/4grr_0152bng1c9jn0zdltsh0000gn/T/pdfsandwichca3e56.pbm Warning: could not determine page size; defaulting to A4. convert -units PixelsPerInch -type Bilevel -density 300x300 "/var/folders/zv/4grr_0152bng1c9jn0zdltsh0000gn/T/pdfsandwich_inputfile68af10.pdf[0]" /var/folders/zv/4grr_0152bng1c9jn0zdltsh0000gn/T/pdfsandwich3c4c04.pbm ERROR: Command "convert -units PixelsPerInch -type Bilevel -density 300x300 "/var/folders/zv/4grr_0152bng1c9jn0zdltsh0000gn/T/pdfsandwich_inputfile68af10.pdf[1]" /var/folders/zv/4grr_0152bng1c9jn0zdltsh0000gn/T/pdfsandwichca3e56.pbm" failed. Terminating pdfsandwich. All temporary files are kept.
Strangely enough, we don't see any specific error message from convert, only the message that it doesn't work. Do you see more if you execute the same command "manually", i.e.
convert -units PixelsPerInch -type Bilevel -density 300x300 "mypdf.pdf[1]" "output.pbm"
Does this work or do you see any error?
Abort trap: 6
After some research, I found that the issue is with the current version of ghostscript (9.27). It occurs on a Mac, with ImageMagick (and ghostscript) installed via Macports. The solution is to downgrade to the prior version of Ghostscript.
Here are a list of commands in case anyone can benefit from them:
When asked if you'd like to rebuild ImageMagick @6.9.9-40+x11, enter 'y'.
Source/credit for this material, and explanation of the commands is available at https://trac.macports.org/wiki/howto/InstallingOlderPort.
I want to thank Tobias for his help pointing me in the right direction.
In my case was this classic issue.