Bug 687373

Summary: how to use AlwaysEmbed/NeverEmbed
Product: Ghostscript Reporter: Bob T. <rdtennent>
Component: DocumentationAssignee: Ralph Giles <ralph.giles>
Status: NOTIFIED FIXED    
Severity: minor    
Priority: P2    
Version: 8.14   
Hardware: All   
OS: Linux   
Customer: Word Size: ---
Attachments: Proposed replacement for ps2pdf.htm documentation

Description Bob T. 2004-03-18 10:39:52 UTC
Ps2pdf.htm doesn't explain or give an example of how these "distiller
parameters" are written as options.  The link given to Adobe's documentation is
dead but I managed to find it; unfortunately, it doesn't help me figure out the
syntax ps2pdf expects. Everything I've tried so far produces either

  Unrecoverable error: typecheck in .putdeviceprops

or

  -dvar=name requires name=null, true, or false

How about a simple example of a command-line with one of these options?
Comment 1 Ralph Giles 2004-03-23 23:16:06 UTC
Always/NeverEmbed are a little special because they take arrays instead of names
or boolean values. I don't believe it's possible to set them using -d on the
command line.

Instead you need to feed ghostscript a postscript string to set these
parameters. For example:

  <</AlwaysEmbed [/Helvetica /Times-Roman]>> setdistillerparams

Now for the real bug. You can do this on the command line with the -c option,
but the way the ps2pdf wrapper counts options assumes any arguments to any
options are not separated by whitespace, and it stupidly complains that you've
given it the wrong number of options. Thus the usage message you mentioned getting.

So the work around is to either insert the above postscript snippet into the
file before you convert it, or to invoke ghostscript manually:

  gs -dBATCH -dSAFER -DNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf -c
'.setpdfwrite <</AlwaysEmbed [/Helvetica /Times-Roman]>> setdistillerparams' -f
in.ps

(this is all the ps2pdf wrapper does)

Comment 2 Bob T. 2004-03-24 04:31:17 UTC
"Now for the real bug."  Thanks for the response but I hope this attitude
doesn't mean that fixing the documentation is considered to be unimportant. One
can imagine how much time users have wasted struggling to use these options over
the years and how much sooner the "real" bug would have been discovered if an
attempt had been made to document how the options should be used. 
Comment 3 Ralph Giles 2004-03-24 14:13:47 UTC
No no, we agree the documentation should be improved. The current docs do at
least suggest the proper route, but some examples would be very helpful given
the artificial limitations of the command options.

I was just pointing out the work around while we decided what to do about the
issue. To wit:

 * ps2pdf the script needs to pass -c arguments properly
 * we need examples in Ps2pdf.htm for how to set the distiller parameters
 * the -d option needs to be smartened up to accept arrays, dicts and strings

We'll do at least the first two in the near term.
Comment 4 Alex Cherepanov 2004-03-25 03:17:36 UTC
There's one more easy improvement. Let's interpret characters that immediately
follow -c . For instance -c.setpdfwrite . Currently they are ignored.
I think the proposed change should be implemented because:
(1) it follows the Un*x tradition.
(2) it follows other GS options, sich a -f
(3) it helps to pass options through the scripts.

This fix has been suggested earlier but it was declined. Now we have
a real case where the fix can help.

Regarding -d option, it reads a PostScript token, and can indeed be 
used to define arrays and strings.

gswin32c -da#(s) -db#{s} -c a == /b load == quit
(s)
{s}

A dictionary is not a PostScript token. So it cannot be created by -d .

BTW, the error message for -d is misleading.
-dvar=name requires name=null, true, or false
Comment 5 Richard Yeh 2005-11-12 01:04:56 UTC
Created attachment 1764 [details]
Proposed replacement for ps2pdf.htm documentation

Please find attached my proposed revision for the ps2pdf documentation,
incorporating a warning to users: "note 13", specifying which parameters cannot
be specified on the ps2pdf command line.


Apart from that, I also converted all intended printable < and > symbols to
&lt; and &gt;.	(The MonoImageDict parameter default value had been appearing
in my browser as <> instead of <<K -1>>.)


I also deleted the extra blank columns that had been present in the parameter
table.


I also inserted the word "the" before the "-c" command line option.
Comment 6 Richard Yeh 2005-11-12 01:09:00 UTC
I (Richard C. Yeh) agree.  I have been using the CutePDF Writer with the ps2pdf 
converter and have been putting options into the "C:\Program Files\Acro 
Software\CutePDF Writer\PDFWrite.rsp" text file, one per line, and I have found:

+ The -d and -s options are interchangeable.
+ Strings must be double-quoted; single quotes cause the CutePDF Writer to fail.
+ The -c option causes the CutePDF Writer to fail.

Please find attached my proposed revision to the ps2pdf.htm documentation, 
incorporating "note 13", warning users which parameters cannot be specified on 
the ps2pdf command line.  Apart from that, I also converted all intended 
printable < and > symbols to &lt; and &gt;.  (The MonoImageDict parameter 
default value had been appearing in my browser as <> instead of <<K -1>>.)  I 
also deleted the extra blank columns that had been present in the parameter 
table.

rcy3 @ cornell.edu


Comment 7 Ray Johnston 2005-11-21 11:00:51 UTC
I've reviewed the suggestions, and added some clarification on the use
of the ps2pdf scripts/.bat files w.r.t. the dictionary parameters and
the use of the -c option. In paticular, the use of the '@' option file
can allow -c options paramters or multiple source files. Although I
perfer the gs command line, it does avoid having to remember all of the
other options that are embedded in the ps2pdf script (like -dSAFER
-dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile= -c .setpdfwrite).

Note that I did test the use of the @ option on unix and windows and it
works OK. It may not work on VMS where the "shell" (I use the term loosely)
treats the '@' as a file containing parameters, but I don't have a VMS
system to test on (they are getting quite rare).