GPL Ghostscript 8.70: Can't start ijs server - pdf

I'm trying to get ghostscript to convert PDFs to PCL-5 (or 5e) using a driver capable of being configured (the built-in drivers produce very surprisingly large output, and I need something capable of being tweaked).
I have gutenprint compiled, and have placed the ijsgutenprint executable at /home/marcintustin/webapps/django/oneclickcosvirt/bin/ijsgutenprint.5.2. When I try to invoke it with ghostscript with
gs -dBATCH -dNOPAUSE -dNOCIE -dSAFER -sDEVICE=ijs \
-sIjsServer=/home/marcintustin/webapps/django/oneclickcosvirt/bin/ijsgutenprint.5.2 \
-sDeviceManufacturer=vendor -sDeviceModel=name -sOutputFile=- - < sztst.pdf > sztst.pcl
I get the error GPL Ghostscript 8.70: Can't start ijs server "/home/marcintustin/webapps/django/oneclickcosvirt/bin/ijsgutenprint.5.2". I am mystified because the file is at the given location, is set executable, and can be invoked without error from the commandline. Any ideas on what's wrong / another way to solve this?
(I'm doing this on a shared host, to which I am not root, so I can't configure system-wide printing, and I'd prefer not to install any printing-related daemons unless absolutely necessary).

The issue was that gutenprint, in addition to the ijsgutenprint.5.2 binary, needs to have in the same directory where the binary is installed a directory called .libs containing further files. (The .objects directory also generated during build is not required in the installation).
Take note if performing a manual install!

Related

GHOSTSCRIPT - PS to PDF conversion paper size

I am trying to run regular conversions of PS to PDF but having some issues with Ghostscript.
Running under normal conditions the output crops the top of the page as you would expect since the PS is configured for A4 but doesn't define a page size.
However, when I use the sPAPERSIZE or change the default in gs_init as described here it prints a blank page.
I tried on a colleges PC who is running adobe distiller and the conversion worked perfectly without issue. I also tried using PDF24 rather than GS directly - it cropped the same but I couldn't find an init file to change.
Unfortunately the PS files are auto generated and so changing them isnt an option.
Windows 10 10.0.17763 x64
GS 9.53.3
PDF24 9.2.2
Adobe Distiller: Version unknown (probably older)
Solved my issue:
C:\Program Files (x86)\gs\gs9.53.3\bin>gswin32c.exe -sOutputFile="output.pdf" -dNOPAUSE -dBATCH -sPAPERSIZE=a4 -sDEVICE=pdfwrite -dSAFER "input.PS"
Solved using a combination of answers from here to get the gs function
https://stackoverflow.com/questions/30128250/ps2pdf-preserve-page-size#:~:text=An%20A4%20page%20has%20a,it%20comes%20to%20PDF%20output
and here to run gs in the command line (unable to get it to work outside of command line)
Keep getting error messages in ghostscript when using the documented ghostscript syntax

Specify default substitution font when converting pdf to image using imagemagick and font is missing

I am using Spatie/pdfToImage that builds on ghost script and imagemagick to on my server:
Take a multiple page pdf from an email using mailgun routing.
Save the pdf in folder /docs_pdf like file.pdf
Use a foreach to loop through each page and save each page as a png to /docs like file_#.png
locally where I use laravel -> valet everything works fine.
On my server using digital ocean through laravel forge the language in a multipaged pdf that is in swedish transforms from normal swedish to a bunch of random letters and signs.
The left is correct (yes, its true. Its Swedish) and the right is wrong:
Someone suggested to me that this is probably a matter of the font missing on the server. The fonts used in the pdf:
<</StemV 68/FontName/PSQHMO+FoundrySans-Normal/FontFile2 216 0 R/FontStretch/Normal/FontWeight 400/Flags 32/Descent -240/FontBBox[-40 -240 960 916]/Ascent 916/FontFamily(FoundrySans-Normal)/CapHeight 667/XHeight 465/Type/FontDescriptor/ItalicAngle 0>>
<</StemV 100/FontName/MLHPWU+FoundrySans-Medium/FontFile2 217 0 R/FontStretch/Normal/FontWeight 400/Flags 32/Descent -241/FontBBox[-42 -241 1008 916]/Ascent 916/FontFamily(FoundrySans-Medium)/CapHeight 667/XHeight 470/Type/FontDescriptor/ItalicAngle 0>>
<</StemV 68/FontName/SUEECI+FoundrySans-Normal/FontFile2 218 0 R/FontStretch/Normal/FontWeight 400/Flags 4/Descent -240/FontBBox[-40 -240 960 916]/Ascent 916/FontFamily(FoundrySans-Normal)/CapHeight 667/XHeight 465/Type/FontDescriptor/ItalicAngle 0>>
<</StemV 48/FontName/KIDDUY+FoundrySans-Light/FontFile2 9 0 R/FontStretch/Normal/FontWeight 400/Flags 32/Descent -248/FontBBox[-28 -248 978 924]/Ascent 924/FontFamily(FoundrySans-Light)/CapHeight 667/XHeight 458/Type/FontDescriptor/ItalicAngle 0>>
Here is configuration of fonts in imagemagick and ghostscript:
https://www.imagemagick.org/script/resources.php
how can this be solved?
Update:
I have now made a clean install on a new server.
Installed Imagick and spatie/pdfToImage
As suggested by KenS I ran
gs -sDEVICE=png16m -o out%d.png
terminal output
forge#Server:~/app/storage/app/public/files$ gs -sDEVICE=png16m -o test_out%d.png file.pdf
GPL Ghostscript 9.22 (2017-10-04)
Copyright (C) 2017 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Page 2
the document rendered the same = wrong.
I am at a complete loss.. Don't know what next step might be..
Update2:
I also run the convert imagemagick commando and the img rendered the same way also.
So even if I do it with ghostscript solo, imagemagick or spatie/pdfToImage it gives me the same output
Well, the current version of Ghostscript (9.25) renders this acceptably for me; that is the text appears to be correct. All the fonts are embedded, so there shouldn't be any problems.
And this means that even if you did replace the default font substitution, it wouldn't help, because Ghostscript shouldn't be using the default font, it will be using the fonts embedded in the PDF file.
Without knowing what version of Ghostscript you are using (I see from a later comment that its 9.25), or the command line that is used to start it, I can't really do a like-for-like comparison. Its hard for me to see how you could be getting such a different result though. That looks like Ghostscript has failed to find the embedded fonts.
Its possible that whatever package you are using has done something 'unfortunate'. The various package maintainers on Linux add their own patches, and sometimes modify the way that Ghostscript is built. Possibly that has broken something.
If you are able to build Ghostscript yourself you could try cloning our Git repository and doing that. You could also try downloading the Linux binaries off our website. They won't work with every Linux distribution (different ABI) but you can try, you might be lucky.
You could also try running Ghostscript directly on the PDF file. Something like:
gs -sDEVICE=png16m -o out%d.png
should produce 2 PNG files, out1.png and out2.png. It will also produce a bunch of stuff on the terminal. That back channel output is valuable information for me so if you can reproduce the problem, I'd like to see that too.
One last thought; its possible to have more than one version of Ghostscript installed simultaneously, its possible that your current setup is using an old version of Ghostscript.
I can't help you with ImageMagick or Spatie, but if you can debug those to the point where you can reproduce the problem with a plain Ghostscript command line then I can look further at it.
Finally got it to work. I want to first give kudos to KenS that really helped me, and without him it would not have worked.
This is what I did:
1 - I removed Ghostscript:
sudo apt-get purge --auto-remove ghostscript
then
wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs925/ghostscript-9.25.tar.gz
tar xvf ghostscript-9.25.tar.gz
Enter the unpacked folder and do
./configure
make
make install
then
sudo ln -s /usr/local/bin/gs /usr/bin/gs
On top of the above I did:
sudo add-apt-repository ppa:glasen/freetype2
and then:
sudo apt update && sudo apt install freetype2-demos

How to print PDF on AIX?

I need to print PDF files from AIX 5.3 system. i tried to used Ghostscript software to convert PDF to postscript files but i get the below message.
$ gs
AFPL Ghostscript 8.54 (2006-05-17)
Copyright (C) 2005 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Xlib: connection to "local:0.0" refused by server
Xlib: Client is not authorized to connect to Server
AFPL Ghostscript 8.54: Cannot open X display `local:0.0'.
**** Unable to open the initial device, quitting.
any help would be appropriated
Thanks
Try using a version of Ghostscript less than 8 years old.....
Basically your command line uses the display device (because you haven't asked for anything else, and that's the default) which on a *nix system is the X client. Clearly you aren't running an X server, so it doesn't work.
You really, really need to be using something more recent, even if you get that ancient version working, the output will be not very good.
gs without arguments tries to open a window, but you are not working in a graphical environment, or it is not set up properly.
I do not know if your ghostscript version is capable enough to convert pdf, but why not give it a try. Graphical environment is not required:
gs -dNOPAUSE -dBATCH -dSAFER -sDEVICE=ps2write -sOutputFile=myfile.ps -f myfile.pdf
More comfortably, see if you have pdf2ps available or if it can be installed. It is a shell script using gs. Just call it like pdf2ps myfile.pdf myfile.ps.

Convert: Postscript delegate failed

I am trying to convert a PDF to JPEG:
$ convert pdf-test.pdf pdf-test.pdf.jpg
However, I am getting this error:
convert: Postscript delegate failed `pdf-test.pdf': No such file or directory # error/pdf.c/ReadPDFImage/664.
convert: missing an image filename `pdf-test.pdf.jpg' # error/convert.c/ConvertImageCommand/3015.
Currently I am using this version of GS and ImageMagick on Mac OS X Lion:
$ gs -v
GPL Ghostscript 9.02 (2011-03-30)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
$ convert -version
Version: ImageMagick 6.7.1-1 2011-07-21 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
Can anybody enlighten me on this?
I was receiving the same error message. I then installed gs and the same command worked properly after that.
Try install GS:
$ brew install gs
Well, its telling you thre is no such file or directory. Presumably you have checked the file exists. Have you tried using ./pdf-test.pdf, or using a fully-qualified path ?
Have you tried opening the file directly with GS rather than using ImageMagick ? Just to check the fact that GS is working properly. Somthinhg like:
gs ./test-pdf.pdf
ought to open the PDF file in a window.
ImageMagick sometimes throws this error when you choose too big resolution. Use -density parameter to limit it, e.g. -density 200.
I've encountered this problem today, and it seemed to relate to the overflowing of the /tmp volume. Specifically, it's the magick-* files that were overflowing the storage.
Freeing up the /tmp files solved the problem for me.
I encountered the same problem with MAMP 3.05 on Mac OS X 10.6.8 when trying to convert PDF files with PHP and Imagick to other formats. Conversion doesn't work and gives an error like "Postscript delegate failed... No such file...".
There is already a "gs" file in /Applications/MAMP/Library/bin/lib which comes when installing MAMP 3.05 package. But unfortunately, this file seems not to be in its good location, and this may explain why Ghostscript doesn't work.
The right place for "gs" file is /usr/bin. I tried to put an alias of the "gs" file from MAMP folder to /usr/bin, but it didn't work.
The good method is to make a new install of GS. Download the installer package from http://pages.uoregon.edu/koch/. The last update is 9.14, but on their site, they tell it is buggy in some cases. For this reason, I prefered to install Ghostscript 9.10.
When downloaded, launch the Ghostscript package. It's very easy ! GS installs itself in /usr/local/bin. Copy the "gs" alias from /usr/local/bin to /usr/bin. To do this, obviously, you must reveal hidden files in the finder with a tool like Onyx, choose your MAC OS X version at http://www.titanium.free.fr/downloadonyx.php
Restart MAMP and/or your computer. Now GS works properly, and PDF files can be converted to other picture formats.
Hope be helpful.
I got an extremely similar error message from PHP/Imagick/GS, it turned out the pdf in question was password-protected / encrypted. So maybe that's another possible cause.

python-django Ghostscript apache problem

When I run my app, that converts pdf to png, from django server, the conversion works fine. But when I run this from an apache server, I am getting this error: GhoscriptError: Fatal. Reading from the sterr of ghostscript, it says
Initialization file gs_init.ps does
not begin with an integer.
It seems an initialization error for me, but I have no idea how to fix this.
Using Ubuntu by the way. gs folder is in the path, so Im not sure if that is causing the problem.
Here's my code that generates the images
def PDF_to_png(input,output):
args = [
"-dSAFER",
"-dBATCH", "-dNOPAUSE", "-sDEVICE=png16m",
"-r300",
"-sOutputFile=" + os.path.join(output,input.file_name_without_extension)+"_%d.png",
input
]
ghostscript.Ghostscript(*args)
The error is telling you that the file gs_init.ps which is normally found in gs/Resource/Init/ is not valid. From the header of the file:
------------------------------------------------------------------------
% Interpreter library version number
% NOTE: the interpreter code requires that the first non-comment token
% in this file be an integer, and that it match the compiled-in version!
902
------------------------------------------------------------------------
You can build GS with the resources built-in or on disk, I don't know which build you get with Ubuntu but it sounds like either there is a gs_init.ps in the GS path which has been damaged. This probably means you are using a version with the resources on disk.
You should first try just starting up Ghostscript. If that works then it's something to do with the environment which is different when you run the failing instance. Look for environment variables which begin GS_ (especially *GS_LIB*). You should also try actually defining where GS should look on the command line by including something like :
-I/usr/src/gs/Resource
This I ncludes the specified directory as a search path for Ghostscript (NB GS does not use the PATH environment variable). GS will search here for initialisation files first before proceeding on its fall back mechanism.