[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

magicfilter and (pdf => postscript) problems


Need to get pdf file printing working using magicfilter.
The printer is a LaserJet 4P (no postscript module)

Looked at the bug reports and came across the suggestion to 
include this line in the ljet-filter file:
	# PDF - Added by CRT 97/05/12
	0       %PDF            pipe    /usr/bin/acroread  -toPostScript   

After experimenting with this, I've come to the conclusion
that, on my machine at least, this is *not* a good idea.  It would
be best to use ghostscript directly.

Assuming a test file name of 'test', I've tried a few experiments.
First of all I needed a .pdf file, and the easiest way to obtain one 
was to create one from a postscript file using ps2pdf.  

to .ps using pdf2ps

Convert test.pdf to a .ps file using pdf2ps.
One time when printing there were a few aesthetic 
problems (the first lines of the 2nd page were overlaid on the 
first page). However at least it did print on the LaserJet.  
Another time the first sheet had some errors (not identical 
to before, but similar: 'operand stack: --nostringval-')
But the main printout was clean.

(in support of above weirdness here is another report:
admitedly using a different printer)

Same again, except final actual viewing and printing done 
in gv.  Again the first sheet had the beginnings of the 2nd
page, but the main printout was good.

Tried a different file.  First it was converted to postscript
using pdf2ps, then viewed with gv and printed.  No problems.

use gv to print .pdf

Secondly the pdf file was viewed directly in gv and printed. 
This time there were problems.  Again the first line of the 2nd 
page followed by a few lines of ghostscript type error messages 
appeared on a first sheet.  However the printout itself
appeared *unblemished* on a separate sheet.

use gs to print .pdf

Thirdly, tried using the magicfilter commandline for postscript
directly on the test.pdf file:

gs -q -dSAFER -dNOPAUSE -r600 -sDEV=ljet4 -sOutputFile=\|lpr test.pdf

This time there were no problems at all. :-)))  One problem with
the above command line is that ghostscript requires a ^D to exit.

The aesthetic problems encountered were probably those documented 
in the file /usr/doc/gs/NEWS.gz

Due to the above success I tried to add the following line to

0	%PDF	filter	/usr/bin/gs -q -dSAFER -dNOPAUSE -r600 -sDEVICE=ljet4 
-sOutputFile=- -

but this again gives the lpd error:
	lpd[16653]: lp: Daemon filter 'f' terminated (13)
My guess is that ghostscript isn't exiting cleanly after the conversion.
The 13 corresponds to value of status.w_termsig in lpd file printjob.c
w_termsig is defined in /usr/include/waitstatus.h

The following DejaNews article seems to be using the same idea tho :-?
admittedly, again, using a different printer ...

catting into gs to ljet4

Using the following command gives errors:

cat index.pdf.ps2pdf | gs  -q -dSAFER -dNOPAUSE -r600 -sDEVICE=ljet4 
-sOutputFile=\|lpr -

The errors are:

Unrecoverable error: ioerror in bytesavailable
Operand stack:
    --nostringval--  --nostringval--

Unexpected interpreter error -12.
Error object: (f80)op(174:bytesavailable)0x802ccf0
Operand stack at 0x80f3478:
0x80faea4: 0x03 file --S-rx--- 0x0001 0x080f6d70
0x80faeac: 0x03 file --S-rx--- 0x0001 0x080f6d70
Execution stack at 0x80f34cc:
0x80fc80c: 0x0f oper --F---e-- 0x0000 0x0801ef80 = %interp_exit
0x80fc814: 0x12 str  --F-rxe-- 0x0000 0x00000000 =
0x80fc81c: 0x03 file --L-rxe-- 0x0001 0x08104048
0x80fc824: 0x05 mpry --G-rxe-- 0x0020 0x0815d694
0x80fc82c: 0x05 mpry --G-rxe-- 0x0057 0x0815db30
0x80fc834: 0x05 mpry --G-rxe-- 0x0039 0x08132c76
Dictionary stack at 0x80f33f4:
0x80fd03c: 0x02 dict --Gwrx--- 0x0000 0x080fd18c
0x80fd044: 0x02 dict --Gwrx--- 0x0000 0x08141e18
0x80fd04c: 0x02 dict --Lwrx--- 0x0000 0x08102090
0x80fd054: 0x02 dict --Lwrx--- 0x0000 0x08102090
0x80fd05c: 0x02 dict --Gwrx--- 0x001c 0x0814fd8c
0x80fd064: 0x02 dict --Gwrx--- 0x0000 0x08158960
0x80fd06c: 0x02 dict --Lwrx--- 0x0815 0x081042dc

to .ps using acroread

Convert test.pdf to a .ps file using acroread.  Obtained a 
postscript file, but when attempting to print to a HPLaserJet4P, 
lpd gave the error:

	lpd[16425]: lp: Daemon filter 'f' terminated (13)

However the same file *would* print fine to a postscript printer.

Investigating further, by grabbing the command used by magicfilter:

gs -q -dSAFER -dNOPAUSE -r600 -sDEVICE=ljet4 -sOutputFile=test.lj4 test.ps

reveals the following error message in gs:

Error: /undefinedresource in true
Operand stack:
   false   --dict:13/13--
Execution stack:
   %interp_exit   ()   --nostringval--   --nostringval--   --nostringval--   
false   --nostringval--   --nostringval--   %runexec_finish   --nostringval--  
 --nostringval--   --nostringval--   --nostringval--   --nostringval--   
--nostringval--   false   --nostringval--   --nostringval--
Dictionary stack:
   --dict:682/701--   --dict:0/20--   --dict:46/200--   --dict:51/75--   
--dict:64/85--   --dict:12/12--
Current allocation mode is local
Current file position is 10931

Tried to open the acroread .ps file in gv and this gives the error:

Unrecoverable error: invalidexit
Unexpected interpreter error -8.
Error object: 
 in .stop
Operand stack:
    true  --nostringval--  false
(f80)op(132:.stop)0x8029680Operand stack at 0x80f3478:
0x80faea4: 0x01 bool --F------ 0x080c 0x00000000 = false
0x80faeac: 0x02 dict --Lwrx--- 0x080f 0x0817aed4
0x80faeb4: 0x01 bool --F------ 0x0000 0x00000001 = true
Execution stack at 0x80f34cc:
0x80fc80c: 0x0f oper --F---e-- 0x0000 0x0801ef80 = %interp_exit
0x80fc814: 0x12 str  --F-rxe-- 0x0000 0x00000000 = 
0x80fc81c: 0x03 file --L-rxe-- 0x0001 0x08104048
0x80fc824: 0x0e null --F---e-- 0x0000 0x08
Error: PostScript interpreter failed in main window

The only advantage of acroread is that it may be able to deal with
passwd protected .pdf files.  Here pdf2ps complains the file is 
encrypted and bombs out.  However there is a solution to this:
see http://www.ozemail.com.au/~geoffk/pdfencrypt/

(BTW: in case someone needs to reproduce anything exactly, 
the testfile I used was a .ps version of this webpage :-)


Hence, in conclusion, I would say: 
- Get magicfilter to treat pdf files like it treats postscript.  In
other words use ghostscript.

- There seem to be problems with pdf2ps.

- Don't use acroread because ghostscript stumbles on files produced by 
acroread.  This means that people without postscript printers will be 
unable to print.  Also, acroread is in contrib ...


ps: Sorry I couldn't digest the information more.  At least its
all there :-)

Package: magicfilter	Version: 1.2-10       
Package: gs-aladdin	Version: 4.03-7      
Package: gv		Version: 2.9.4-3

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .

Reply to: