[pdftex] Printing problems with \pdfcrypt in pdftex-pretest-1.00a

Heiko Oberdiek oberdiek at ruf.uni-freiburg.de
Fri Aug 24 14:13:42 CEST 2001

On Tue, 21 Aug 2001, Berthold Crysmann wrote:

> I have noticed that pdftex pretest 1.00a produces files that may not
> print on some Unix spool systems (e.g. CUPS with non-ps printer), if the
> \pdfcrypt primitive is used. The reason for the print failure is that
> the PS file generated by AR 4.05 cannot be piped to gs. CUPS (and other
> spool systems), however, pipe to a gs backend on systems without a ps
> printer.
> Here's a simple procedure to reproduce the bug:
> 1. Generate document with pdfTeX, Version 3.14159-1.00a-pretest-20010806
> and \pdfcrypt noedit in the preamble
> 2. Open in AR4.05 and print to file pdfcrypttest.ps
> 3. Open with ghostscript: `gs pdfcrypttest.ps' should work, `cat
> pdfcrypttest.ps| gs -'  should fail.

The problem is following PostScript code:

currentfile eexec

The code can be decrypted by gs's eexecDecode filter.
The result is correct PostScript code:

/currentdistillerparams where { pop /pdfmark where
{ pop (The owner of this file does not permit its conversion to PDF.)
print quit}if }if
end PDFVars begin PDF begin PDFVars/InitAll get
currentfile closefile |

* The first "end" closes statusdict that is put on
  the dictionary stack by eexec.
* | marks the end of the decrypted code.
The last space ends the name "closefile", the encrypted
part is so finished and the following "exec" will
execute "InitAll", previously pushed on the stack.

I assume, the problem is the detection of the
encrypted text. Perhaps gs reads (buffers) the
next characters and sees "ex", the first letter
is a valid hex letter, but "x" is not. If gs is
not in pipe modus, it can go back before the "e".
But in pipe modus, gs can not go back and throws
the two "wrong hex" letters away probably.
The remaining "ec" results then in an undefined
error message.

Workaround: adding a comment line after the hex code
before "exec". So the end can be more safely detected.
And no problem arises, if the percent char is thrown


Or in a pipe, it can be automated to add an empty
comment line before each "exec" line:

cat test.ps | perl -p -e 's/^exec$/%\nexec/' | gs -

Yours sincerely
  Heiko <oberdiek at uni-freiburg.de>

More information about the pdftex mailing list