RightmireM
RightmireM

Reputation: 2492

Django or Python, how to convert postscript to PDF or Image

I'm running a RHEL7 system as a web server using Django 1.8.2

I'm researching a solution where a PostScript (PS) file can be uploaded by a Django API and is then converted to either a PDF or Image (such as JPG or PNG).

I put Django or Python, since it doesn't matter whether Django handles the conversion, or passes it off to a pure Python script and receives the result back.

I've been looking into Ghostscript, but I'm coming up with this error...

$ gs -sDEVICE=pdfwrite -sOutputFile=test.pdf -dBATCH -dNOPAUSE file.ps 
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusMonL-Regu font from /usr/share/fonts/type1/gsfonts/n022003l.pfb... 2849640 1507460 4012484 2498014 1 done.
%%[ Error handled by opdfread.ps : undefined; OffendingCommand: 9!_NGH!_NGH! ]%%
%%[STACK:
--nostringval--
14
%%]%

Open to any solutions. Thanks!

===

@KenS Thanks for pointing out my failure to include an example of the PS file.

file.ps

Upvotes: 3

Views: 3052

Answers (1)

KenS
KenS

Reputation: 31159

It looks like your (PostScript) file was originally produced by using Ghostscript to convert a PDF to PostScript. It also looks very much like your PostScript file has been corrupted, it is trying to interpret binary (probably image) data as language tokens.

This may possibly have happened as a result of CR/LF translation, but in any event the reason Ghostscript is throwing you an error is because your PostScript program is broken. It doesn't matter what software you try to use on it, it won't work, the program is (most likely irretrievably) broken.

Of course this is speculation, since you have not posted a URL to the PostScript file.

I'd suggest that you try with one of the sample files in the Ghostscript folder, such as tiger or golfer, those are known to work.

You should also consider using a more up to date version of Ghostscript, 9.05 is 3 years old now.

Upvotes: 1

Related Questions