So I want to use Ghostscript to convert files that are created in PCL format to PostScript.
That's the gist of my problem. I am simply trying to run it on the command line, but in the final stage it will have to be run on a lp command like
lp -d < gs something something
GPL Ghostscript 9.00 (2010-09-14)
I will be running this on a Solaris 10 server but I believe any Unix system should work similar.
bash-3.00# /usr/local/bin/gs -sDEVICE=pswrite -dLanguageLevel=1 -dNOPAUSE -dBATCH -dSAFER -sOutputFile=output.ps cms-form.pcl
GPL Ghostscript 9.00 (2010-09-14)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in &k2G-210z100u0l6d0e63fa0V
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1910 1 3 %oparray_pop 1909 1 3 %oparray_pop 1893 1 3 %oparray_pop 1787 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1154/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
Current file position is 30
GPL Ghostscript 9.00: Unrecoverable error, exit code 1
You are using Ghostscript (gs), which cannot read-in and interprete PCL.
You should use from GhostPDL the component that interpretes PCL: the executable is called pspcl6.
Then a command like
pspcl6 ^
-o out.pdf ^
-sDEVICE=pdfwrite ^
in.pcl
should convert your PCL to PDF. For PostScript Level 2 use -sDEVICE=ps2write.
However, it may be difficult to find pre-compiled binaries of pspcl6. It's not well known, despite it being part of the Ghostscript family of products. You may need to build + compile your own version from the sources.
Update:
http://code.google.com/p/ghostscript/downloads/detail?name=ghostpdl-8.71-win32.zip
http://code.google.com/p/ghostscript/downloads/list
Related
Have recently upgrade to imagemagick 7.0.8-14 and have lost the ability to convert a pptx file to a jpg(or any other file format). Was working version before upgrade. The below is the out put from running the convert cmd. Happens on all pptx that have been run against it.
imagemagick version: 7.0.8-14
ghostscript version: 9.07
centos 7
$ convert test.pptx[0] -thumbnail 650x650 -gravity center -extent 1500x1000 s1.jpg
\convert /tmp/magick-17292VzAbA_mfaxJX -> /tmp/magick-17292VzAbA_mfaxJX.pdf using filter : impress_pdf_Export
convert: PDFDelegateFailed `[ghostscript library 9.07] -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pngalpha' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dFirstPage=1 -dLastPage=1 '-sOutputFile=/tmp/magick-17292RtJq2Z8iF5iK%d' '-f/tmp/magick-17292wskX7eyNic7t' '-f/tmp/magick-17292jHMWYZOpLjVd'': **** Warning: Dropping incorrect smooth shading object.
**** File did not complete the page properly and may be damaged.
Error: /rangecheck in --run--
Operand stack:
-1 --nostringval--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1884 1 3 %oparray_pop 1883 1 3 %oparray_pop 1867 1 3 %oparray_pop --nostringval-- --nostringval-- 2 1 1 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- false 1 %stopped_push --nostringval-- --nostringval--
Dictionary stack:
--dict:946/1684(ro)(G)-- --dict:1/20(G)-- --dict:82/200(L)-- --dict:82/200(L)-- --dict:109/127(ro)(G)-- --dict:292/300(ro)(G)-- --dict:27/32(L)-- --dict:6/8(L)-- --dict:21/40(L)--
Current allocation mode is local
GPL Ghostscript 9.07: Unrecoverable error, exit code 1
# error/pdf.c/InvokePDFDelegate/276.
convert: no images defined `s1.jpg' # error/convert.c/ConvertImageCommand/3288.
could you share your current version of Ghostscript by running the below command?
rpm -qa ghostscript
In case the version is anything above and including 9.07-31.el7_6.1, could you try to downgrade to 9.07-31 and report if it is fixing your problem? To downgrade to that version, run the below command:
yum downgrade ghostscript-9.07-31.el7
If this was fixing your problem, I would be more than happy if you could share the pptx file with me (if possible).
For more info, see:
https://bugzilla.redhat.com/show_bug.cgi?id=1657694
This problem should be fixed now with a release of ghostscript-9.07-31.el7_6.6.
Kind regards,
-Martin
So I have some Lua bytecode, and now I would like to re-compile it into human readable code:
\27\76\117\97\81\0\1\4\8\4\8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\2\4\0\0\0\5\0\0\0\65\64\0\0\28\64\0\1\30\0\128\0\2\0\0\0\4\6\0\0\0\0\0\0\0\112\114\105\110\116\0\4\9\0\0\0\0\0\0\0\72\105\32\116\104\101\114\101\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
How would I achieve this? I have tried using LuaDec, but I get the following error:
bad header in precompiled chunk
If anyone could help me that would be excellent.
Step 1
Write your bytecode into a file
local str = '\27\76\117\97\81\0\1\4\8\4\8\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\2\2\4\0\0\0\5\0\0\0\65\64\0\0\28\64\0\1\30\0\128\0\2\0\0\0\4\6\0\0\0\0\0\0\0\112\114\105\110\116\0\4\9\0\0\0\0\0\0\0\72\105\32\116\104\101\114\101\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'
local file = io.open("bytecode.lua", "wb")
file:write(str)
file:close()
Step 2
Install Lua 5.1 (see lua.org for details)
Step 3
Run luac to view the content of bytecode
$ ~/lua-5.1.5/src/luac -l -l -p bytecode.lua
main <?:0,0> (4 instructions, 16 bytes at 0x19fd550)
0+ params, 2 slots, 0 upvalues, 0 locals, 2 constants, 0 functions
1 [-] GETGLOBAL 0 -1 ; print
2 [-] LOADK 1 -2 ; "Hi there"
3 [-] CALL 0 2 1
4 [-] RETURN 0 1
constants (2) for 0x19fd550:
1 "print"
2 "Hi there"
locals (0) for 0x19fd550:
upvalues (0) for 0x19fd550:
Step 4
Convert bytecode instructions manually into Lua source text :-)
print("Hi there")
Decompilation complete.
I am trying to convert pdf file(which is scanned image with extension .pdf) into .jpg which is having multi pages using Python 3.6 with PythonMagick 0.9.13, ghostscript 0.6. All have been installed from PyCharm Interpreter Package.
OS-Windows10 64 bit
It was working fine for some time, but now its giving me an below error, i tried to find fix this by looking into suggestions given in all below links, nothing worked out. Can any one please help me to fix this? it would be great!!
Error with ImageMagick and Ghostscript converting from PDF
Imagemagick Convert PDF to JPEG: FailedToExecuteCommand `"gswin32c.exe" / PDFDelegateFailed
****************************Error Message********************
RuntimeError: Magick: PDFDelegateFailed `[ghostscript library 9.09] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pamcmyk32" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor -dFirstPage=1 -dLastPage=1 "-sOutputFile=C:/Users/****/AppData/Local/Temp/magick-13092f9RE6HZSrtFU%d" "-fC:/Users/****/AppData/Local/Temp/magick-13092ks9r_NT8Xygw" "-fC:/Users/****/AppData/Local/Temp/magick-13092NNqfnGb-iNhM"': Unrecoverable error: invalidaccess in put
Operand stack:
true false --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- InputAttributes --nostringval-- --nostringval-- InputAttributes --nostringval--
# error/pdf.c/InvokePDFDelegate/274
Looks like you have an invalid PDF file. You also have an ancient version of Ghostscript, 9.09 is 5 years old and I'd start by trying the current version instead.
I'd also try just opening the PDF file with Ghostscript to see whether that works, if it doesn't then I'd need to have the original PDF file to say why.
One thing that is relevant, though you may not be able to change it, is; Don't use -dUseCIEColor.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am trying to use ghoshscript to convert a pdf in image.
The PDF is : http://www.coppernet.zm/MPLS.pdf
$ sudo docsplit images -o /tmp/previews -p 1-5 -s 150,750,1000 -f png MPLS.pdf
While reading gs_cidfm.ps:
Error: /rangecheck in --.dicttomark--
Operand stack:
(gs_cidfm.ps) 1 --nostringval-- 1 Arial --dict:4/4(G)--
Execution stack:
%interp_exit --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push --nostringval-- --nostringval-- --nostringval--
Dictionary stack:
--dict:956/1123(G)-- --dict:0/20(G)-- --dict:64/200(L)-- --dict:956/1123(G)-- --dict:8/14(G)-- --dict:1/1(G)--
Current allocation mode is global
Current file position is 4622
Unrecoverable error: undefined in .uninstallpagedevice
Operand stack:
gs_cidfm.ps 1 --nostringval-- 1 Arial --nostringval--
gm convert: "gs" "-q" "-dBATCH" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=pnmraw" "- dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r150x150" "-dFirstPage=1" "-dLastPage=1" " sOutputFile=/tmp/d20121211-1674-zs83qu/gme03xr0" "--" "/tmp/d20121211-1674-zs83qu/gmcjhLqq" "-c" "quit".
gm convert: Postscript delegate failed (MPLS.pdf).
I tryied to apply this : http://thomas-genin.com/ghostscript-convert-error-undefined-in-findresource/ and it creates this error.
EDIT: If I remove the /var/lib/ghostscript/fonts/cidfmap file I don't have the error anymore.
1 /Arial << /FileType /TrueType /Path (/usr/share/fonts/truetype/msttcorefonts/arial.ttf) /SubfontID 0 /CSI [(Artifex) (Unicode) 0] >> ;
You don't say what version of Ghostscript you are using, and because you are using something which executes Ghostscript you haven't given me a command line I can actually try.
However, on the assumption that the (ImageMagick?) command line in the error is the one being used, I rendered your PDF file to PNM without problems using a copy of the current code, so I suspect that this is resolved, I would recommend you upgrade to the current version.
If this doesn't solve the problem, then you should open a bug report at http://bugs.ghostscript.com please attach the PDF file there, and supply a Ghostscript command line which demonstrates the problem.
I have a couple processes running a tool I've written that are joined by pipes, and I would like to measure their collected memory usage with valgrind. So far, I have tried something like:
$ valgrind tool=massif trace-children=yes --peak-inaccuracy=0.5 --pages-as-heap=yes --massif-out-file=myProcesses".%p" myProcesses.script
Where myProcesses.script runs the equivalent of my tool foo twice, e.g.:
foo | foo > /dev/null
Valgrind doesn't seem to capture the collected memory usage of this the way I expect. If I use top to track this, I get (for sake of argument) 10% memory usage on the first foo, and then another 10% collects on the second foo before the myProcesses.script completes. This is the sort of thing I want to measure: the usage of both processes. Valgrind instead returns the following error:
Massif: ms_main.c:1891 (ms_new_mem_brk): Assertion 'VG_IS_PAGE_ALIGNED(len)' failed.
Is there a way to collect memory usage data for commands I'm using in a piped fashion (using valgrind)? Or a similar tool that I can use to accurately automate these measurements?
The numbers that top returns while polling seem hand-wavy, to me, and I am seeking accurate and repeatable measurements. If you have suggestions for alternative tools, I would welcome those, as well.
EDIT - Fixed typo with valgrind option.
EDIT 2 - For some reason, it appears that the option --pages-as-heap is giving us troubles with the binaries we're testing. Your examples run fine. A new page is created every time we enter a non-inlined function (stack overflows - heh). We wanted to count those, but they're relatively minor in the scale of memory usage we're testing. (Perhaps there aren't function calls in ls or less?) Removing --pages-as-heap helped get testing working again. Thanks to MrGomez for the great help.
With the correct valgrind version given in the errata, this seems to just work for me in Valgrind 3.6.1. My invocation:
<me>#harley:/tmp/test$ /usr/local/bin/valgrind --tool=massif \
--trace-children=yes --peak-inaccuracy=0.5 --pages-as-heap=yes \
--massif-out-file=myProcesses".%p" ./testscript.sh
==21067== Massif, a heap profiler
==21067== Copyright (C) 2003-2010, and GNU GPL'd, by Nicholas Nethercote
==21067== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==21067== Command: ./testscript.sh
==21067==
==21068== Massif, a heap profiler
==21068== Copyright (C) 2003-2010, and GNU GPL'd, by Nicholas Nethercote
==21068== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==21068== Command: /bin/ls
==21068==
==21070== Massif, a heap profiler
==21070== Copyright (C) 2003-2010, and GNU GPL'd, by Nicholas Nethercote
==21070== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==21069== Massif, a heap profiler
==21069== Copyright (C) 2003-2010, and GNU GPL'd, by Nicholas Nethercote
==21069== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
==21069== Command: /bin/sleep 5
==21069==
==21070== Command: /usr/bin/less
==21070==
==21068==
(END) ==21069==
==21070==
==21067==
The contents of my test script, testscript.sh:
ls | sleep 5 | less
Sparse contents from one of the files generated by --massif-out-file=myProcesses".%p" (myProcesses.21055):
desc: --peak-inaccuracy=0.5 --pages-as-heap=yes --massif-out-file=myProcesses.%p
cmd: ./testscript.sh
time_unit: i
#-----------
snapshot=0
#-----------
time=0
mem_heap_B=110592
mem_heap_extra_B=0
mem_stacks_B=0
heap_tree=empty
#-----------
snapshot=1
#-----------
time=0
mem_heap_B=118784
mem_heap_extra_B=0
mem_stacks_B=0
heap_tree=empty
...
#-----------
snapshot=18
#-----------
time=108269
mem_heap_B=1708032
mem_heap_extra_B=0
mem_stacks_B=0
heap_tree=peak
n2: 1708032 (page allocation syscalls) mmap/mremap/brk, --alloc-fns, etc.
n3: 1474560 0x4015E42: mmap (mmap.S:62)
n1: 1425408 0x4005CAC: _dl_map_object_from_fd (dl-load.c:1209)
n2: 1425408 0x4007109: _dl_map_object (dl-load.c:2250)
n1: 1413120 0x400CEEA: openaux (dl-deps.c:65)
n1: 1413120 0x400D834: _dl_catch_error (dl-error.c:178)
n1: 1413120 0x400C1E0: _dl_map_object_deps (dl-deps.c:247)
n1: 1413120 0x4002B59: dl_main (rtld.c:1780)
n1: 1413120 0x40140C5: _dl_sysdep_start (dl-sysdep.c:243)
n1: 1413120 0x4000C6B: _dl_start (rtld.c:333)
n0: 1413120 0x4000855: ??? (in /lib/ld-2.11.1.so)
n0: 12288 in 1 place, below massif's threshold (01.00%)
n0: 28672 in 3 places, all below massif's threshold (01.00%)
n1: 20480 0x4005E0C: _dl_map_object_from_fd (dl-load.c:1260)
n1: 20480 0x4007109: _dl_map_object (dl-load.c:2250)
n0: 20480 in 2 places, all below massif's threshold (01.00%)
n0: 233472 0xFFFFFFFF: ???
#-----------
snapshot=19
#-----------
time=108269
mem_heap_B=1703936
mem_heap_extra_B=0
mem_stacks_B=0
heap_tree=empty
#-----------
snapshot=20
#-----------
time=200236
mem_heap_B=1839104
mem_heap_extra_B=0
mem_stacks_B=0
heap_tree=empty
Massif continues to complain about heap allocations in the remainder of my files. Note this is very similar to your error.
I theorize that your version of valgrind was built in debug mode, causing the asserts to fire. A rebuild from source (I used this with the defaults hanging off ./configure) will fix the issue.
Either way, this seems to be expected with Massif.
Some programs allow you to preload the libmemusage.so library and get a report of what memory allocations were allocated recorded:
$ LD_PRELOAD=libmemusage.so less /etc/passwd
Memory usage summary: heap total: 36212, heap peak: 35011, stack peak: 15008
total calls total memory failed calls
malloc| 39 5985 0
realloc| 3 64 0 (nomove:2, dec:0, free:0)
calloc| 238 30163 0
free| 51 11546
Histogram for block sizes:
0-15 128 45% ==================================================
16-31 13 4% =====
32-47 105 37% =========================================
48-63 2 <1%
64-79 4 1% =
80-95 5 1% =
96-111 3 1% =
112-127 3 1% =
160-175 1 <1%
192-207 1 <1%
208-223 2 <1%
256-271 1 <1%
432-447 1 <1%
560-575 1 <1%
656-671 1 <1%
768-783 1 <1%
944-959 1 <1%
1024-1039 2 <1%
1328-1343 1 <1%
2128-2143 1 <1%
3312-3327 1 <1%
7952-7967 1 <1%
8240-8255 1 <1%
Though I must admit that it doesn't always work -- LD_PRELOAD=libmemusage.so ls never reports anything, for example -- and I wish I knew the conditions that allow it to work or not work.