Creating High Resolution PDF files for book production with Open Source tools

by Markus Neteler

A common problem for book authors is the delivering of their book in acceptable form as digital file. While Latex is doing a great job, a few tricks have to be known to prepare the book file correctly. Nowadays book editors seem to prefer high quality PDF files instead of Postscript files. This document describes how to arrive at an acceptable PDF file by using Open Source/Free Software tools. Important to know is that prepress machines seem not to provide any font! So all fonts need to be embedded.

This page reflects our experiences with a major publisher; finally, after trying various ways, we found a simple solution which we explain below.

Installation prerequisites:

Recommendations for final PDF file:

Figures, diagrams, ...

Fonts

The conversion from DVI to PDF:

Heart-and-soul of having success is to convert the DVI file correctly to high resolution PDF. The following code is a real world example for a book published by Kluwer Academic Publishers/Springer, Boston/New York:
#prepare the DVI file:
latex mybook.tex
bibtex mybook.tex
latex mybook.tex

#render the high resolution PDF from the DVI file:
export MYBOOKDVI=mybook.dvi
export MYBOOKPDF=mybook_highres.pdf

#MANDRAKE 9.1:
DVIPS=dvips -j0 -Ppdf -Pdownload35 -G0 -t letter -D 1200 -Z -mode ljfzzz

#REDHAT 9 (ar-std-urw-kb.map,ar-ext-urw-kb.map : assume K Berry names - Kluwer however uses 'Dvipsone' names):
# Note: there is a bug in the font mapping on Redhat9 (mtsupp-std-urw-urw.map contains Nimbus...):
#       however, it works fine on Mandrake.
#DVIPS=dvips -j0 -Ppdf -u ps2pk.map -G0 -t letter -D 1200 -Z -mode ljfzzz

#SuSe:
# ... seems to be similar to Redhat9 ...

#Notes:
# -j0 -G0: tells dvips to embed the fonts 100%
# -Pdownload35 or -u ps2pk.map: configuration of PostScript Type 1 fonts
# - Dvipsone Names: they have to be activated in the style file of the publisher

${DVIPS} ${MYBOOKDVI} -o - | gs -q -dNOPAUSE -dBATCH \
	-sDEVICE=pdfwrite -dPDFSETTINGS=/prepress\
	-dCompatibilityLevel=1.3 \
	-dCompressPages=true -dUseFlateCompression=false \
	-sPAPERSIZE=letter \
	-dSubsetFonts=true -dEmbedAllFonts=true \
	-dProcessColorModel=/DeviceGray \
	-dDetectBlends=true -dOptimize=true \
	-dDownsampleColorImages=true -dColorImageResolution=1200 \
	-dColorImageDownsampleType=/Average -dColorImageFilter=/FlateEncode \
	-dAutoFilterColorImages=false -dAntiAliasColorImages=false \
	-dColorImageDownsampleThreshold=1.50000 \
	-dDownsampleGrayImages=true -dGrayImageResolution=1200 \
	-dGrayImageDownsampleType=/Average -dGrayImageFilter=/FlateEncode \
	-dAutoFilterGrayImages=false -dAntiAliasGrayImages=false \
	-dGrayImageDownsampleThreshold=1.50000 \
	-dDownsampleMonoImages=true -dMonoImageResolution=1200 \
	-dMonoImageDownsampleType=/Average -dMonoImageFilter=/FlateEncode \
	-dAutoFilterMonoImages=false -dAntiAliasMonoImages=false \
	-dMonoImageDownsampleThreshold=1.50000 \
	-sOutputFile=${MYBOOKPDF} \
	-c save pop -

#now you should find the PDF in the local directory.
Of course you can insert above into a neat script (e.g. a Makefile to create the DVI/PDF files).

The publisher's PDF preflight should now run well.


FAQ - Frequently asked questions

  1. Font problems - you see something like this in ps2pdf:
       dvips: Font Helvetica used in file figures/gstat_ln_zinc1.eps is not in the mapping file.
       dvips: Font Helvetica-Bold used in file figures/R_ecdf_elev_int.eps is not in the mapping file.
       dvips: Font Helvetica-Oblique used in file figures/R_ecdf_elev_int.eps is not in the mapping file.
       dvips: Font Helvetica-BoldOblique used in file figures/R_ecdf_elev_int.eps is not in the mapping file.
       dvips: Font Symbol used in file figures/R_ecdf_elev_int.eps is not in the mapping file.
     
    or something like this in Acrobat Distiller (prepress settings):
       %%[ Warning: Helvetica not found, using Font Substitution. Font cannot be embedded.]%% 
     

    This problem can be solved by changing the fonts in the EPS file(s). The problem arises from the fact that standard PostScript fonts are not embedded, but for prepress stage we need all fonts embedded.

    Solution: You can happily edit EPS files with a text editor (nedit, gedit, ...) and replace the font names according to this table:

     Name Translation table:
     GhostScript fonts                     | PostScript name   | 	URW Name (use for embedding)
     --------------------------------------+-------------------+-----------------------------
      Nimbus Sans L Regular			 Helvetica		NimbusSanL-Regu
      Nimbus Sans L Regular Italic		 Helvetica		NimbusSanL-ReguItal
      Nimbus Sans L Bold			 Helvetica		NimbusSanL-Bold
      Nimbus Sans L Bold Italic		 Helvetica		NimbusSanL-BoldItal
      Nimbus Sans L Regular Condensed 	 Helvetica Narrow	NimbusSanL-ReguCond
      Nimbus Sans L Regular Condensed Italic Helvetica Narrow	NimbusSanL-ReguCondItal
      Nimbus Sans L Bold Condensed		 Helvetica Narrow	NimbusSanL-BoldCond
      Nimbus Sans L Bold Condensed Italic 	 Helvetica Narrow	NimbusSanL-BoldCondItal
      Nimbus Roman No9 L Regular	 	 Times			NimbusRomNo9L-Regu
      Nimbus Roman No9 L Regular Italic 	 Times			NimbusRomNo9L-ReguItal
      Nimbus Roman No9 L Medium 		 Times			NimbusRomNo9L-Medi
      Nimbus Roman No9 L Medium Italic 	 Times			NimbusRomNo9L-MediItal
      Standard Symbols L 			 Symbol			StandardSymL
      [...]
     --------------------------------------+-------------------+-----------------------------
     
    Example: After changing 'Helvetica' to 'NimbusSanL-Regu' in the EPS file, this font will be embedded into the final PDF file.

    Since we are lazy, we let the computer do this change-the-names job:

      # We go for replacing the wrong commercial font names with URW names, we also
      # adapt some similar fonts names on the fly (extend for further font names):
    
      cat original_graphics.eps | sed 's+Times-Bold+NimbusSanL-Bold+g' |\
       sed 's+Times-Roman+NimbusSanL-Regu+g' |\
       sed 's+Times+NimbusSanL-Regu+g' |\
       sed 's+Helvetica-BoldOblique+NimbusSanL-BoldItal+g' |\
       sed 's+Helvetica-Oblique+NimbusSanL-ReguItal+g' |\
       sed 's+Helvetica-Bold+NimbusSanL-Bold+g' |\
       sed 's+Helvetica-Bold-iso+NimbusSanL-Bold+g' |\
       sed 's+Helvetica+NimbusSanL-Regu+g' |\
       sed 's+Helvetica-iso+NimbusSanL-Regu+g' |\
       sed 's+Symbol+StandardSymL+g' > new_graphics.eps
     
    Now use the fixed EPS files in your Latex document, the changed names will enforce the font embedding into the final PDF file.

  2. Preparation of EPS files from raster images with OpenOffice/StarOffice:
    When exporting to EPS OpenOffice has 2 options for Text settings:
    - Always export glyph outlines
    - Never export glyph outlines
    The default is 'Always export...' and that integrates the text into image. When changing to 'Never export...' the fonts get defined in the EPS file (we checked it in a text editor so we know that it is in there).

    However, the EPS file from OpenOffice was still different from the one from StarOffice, so StarOffice might be preferred to create EPS. StarOffice does not have the Text settings option and always includes the font definition. When keeping fonts e.g. Times-Bold the resulting EPS file must be run through above 'sed' script to change to Nimbus.

  3. How to convert a PS file to EPS?

    The only functional program is ps2eps from Roland Bless. All other programs are rubbish.

Further Reading

While most publisher's pages do not address the above issues, here is a list of helpful documents:
© 2004 Markus Neteler (neteler AT osgeo.org)
Back HOME
Last change: $Date: 2009-08-18 22:54:45 +0200 (Tue, 18 Aug 2009) $