50. PostScript
This chapter includes applications that create, manipulate or view PostScript files and create or view Portable Document Format PDF files.
50.1 Enscript-1.6.6
Introduction to Enscript
Enscript converts ASCII text files to PostScript, HTML, RTF, ANSI and overstrikes.
This package is known to build and work properly using an LFS 11.3 platform.
Caution
Enscript cannot convert UTF-8 encoded text to PostScript. The issue is discussed in detail in the Needed Encoding Not a Valid Option section of the Locale Related Issues page. The solution is to use paps-0.7.1, instead of Enscript, for converting UTF-8 encoded text to PostScript.
Package Information
-
Download (HTTP): https://ftp.gnu.org/gnu/enscript/enscript-1.6.6.tar.gz
-
Download (FTP): ftp://ftp.gnu.org/gnu/enscript/enscript-1.6.6.tar.gz
-
Download MD5 sum: 3acc242b829adacabcaf28533f049afd
-
Download size: 1.3 MB
-
Estimated disk space required: 14 MB
-
Estimated build time: 0.1 SBU
Enscript Dependencies
Optional
texlive-20220321 (or install-tl-unx)
User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/Enscript
Installation of Enscript
Install Enscript by running the following commands:
./configure --prefix=/usr \
--sysconfdir=/etc/enscript \
--localstatedir=/var \
--with-media=Letter &&
make &&
pushd docs &&
makeinfo --plaintext -o enscript.txt enscript.texi &&
popd
If you have texlive-20220321 installed, you can create Postscript and PDF documentation by issuing (does not support parallel make):
make -j1 -C docs ps pdf
To test the results, issue: make check.
Now, as the root user:
make install &&
install -v -m755 -d /usr/share/doc/enscript-1.6.6 &&
install -v -m644 README* *.txt docs/*.txt \
/usr/share/doc/enscript-1.6.6
If you built Postscript and PDF documentation, install it using the following command as the root user:
install -v -m644 docs/*.{dvi,pdf,ps} \
/usr/share/doc/enscript-1.6.6
Command Explanations
--sysconfdir=/etc/enscript: This switch puts configuration data in /etc/enscript instead of /usr/etc.
--localstatedir=/var: This switch sets the directory for runtime data to /var instead of /usr/var.
--with-media=Letter: This switch sets the medium format to letter size instead of the A4 default.
Contents
Installed Programs: diffpp, enscript, mkafmmap, over, sliceprint, and states
Installed Libraries: None
Installed Directories: /etc/enscript, /usr/share/doc/enscript-1.6.6, and /usr/share/enscript
Short Descriptions
diffpp converts diff output files to a format suitable to be printed with enscript.
enscript is a filter, used primarily by printing scripts, that converts ASCII text files to PostScript, HTML, RTF, ANSI and overstrikes.
mkafmmap creates a font map from a given file.
over is a script which calls enscript and passes the correct parameters to create overstriked fonts.
sliceprint slices documents with long lines.
states is an awk-like text processing tool with some state machine extensions. It is designed for program source code highlighting and for similar tasks where state information helps input processing.
50.2 ePDFView-0.1.8
Introduction to ePDFView
ePDFView is a free standalone lightweight PDF document viewer using Poppler and GTK+ libraries. It is a good replacement for Evince as it does not rely upon GNOME libraries.
This package is known to build and work properly using an LFS 11.3 platform.
Package Information
-
Download (HTTP): https://anduin.linuxfromscratch.org/BLFS/epdfview/epdfview-0.1.8.tar.bz2
-
Download MD5 sum: e50285b01612169b2594fea375f53ae4
-
Download size: 456 KB
-
Estimated disk space required: 6 MB
-
Estimated build time: less than 0.1 SBU
Additional Downloads
ePDFView Dependencies
Required
GTK+-2.24.33 and Poppler-23.02.0
Recommended (mainly for Desktop Environments)
desktop-file-utils-0.26 and hicolor-icon-theme-0.17
Optional
User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/epdfview
Installation of ePDFView
Install ePDFView by running the following commands:
patch -Np1 -i ../epdfview-0.1.8-fixes-2.patch &&
./configure --prefix=/usr &&
make
This package does not come with a test suite.
Now, as the root user:
make install
For Desktop Environment users, further (optional) instructions are necessary for properly displaying epdfview.desktop in the menu. As root user:
for size in 24 32 48; do
ln -svf ../../../../epdfview/pixmaps/icon_epdfview-$size.png \
/usr/share/icons/hicolor/${size}x${size}/apps
done &&
unset size &&
update-desktop-database &&
gtk-update-icon-cache -t -f --include-image-data /usr/share/icons/hicolor
Command Explanations
patch -Np1 -i ../epdfview-0.1.8-fixes-2.patch The patch does four things: fixes compiling with glib-2.32 or greater, corrects red appearing as blue with recent versions of poppler, allows the application to compile when Cups-2.4.2 has been installed, and fixes the display of embedded png images.
Contents
Installed Program: epdfview
Installed Libraries: None
Installed Directory: /usr/share/epdfview
Short Descriptions
epdfview is a Gtk+-2 program for viewing PDF documents.
50.3 fop-2.8
Introduction to fop
The FOP (Formatting Objects Processor) package contains a print formatter driven by XSL formatting objects (XSL-FO). It is a Java application that reads a formatting object tree and renders the resulting pages to a specified output. Output formats currently supported include PDF, PCL, PostScript, SVG, XML (area tree representation), print, AWT, MIF and ASCII text. The primary output target is PDF.
This package is known to build and work properly using an LFS 11.3 platform.
Package Information
-
Download (HTTP): https://archive.apache.org/dist/xmlgraphics/fop/source/fop-2.8-src.tar.gz
-
Download MD5 sum: 610bfd7797755d744b2c4f61422478cf
-
Download size: 22 MB
-
Estimated disk space required: 517 MB (including files downloaded to the user directory)
-
Estimated build time: 0.6 SBU
Additional Downloads
Required Additional Downloads:
-
PDFBox:
https://archive.apache.org/dist/pdfbox/2.0.27/pdfbox-2.0.27.jar
ddd46402b1692eed9e5c73b4a94c45d8
2.7 MB -
PDFBox Fonts:
https://archive.apache.org/dist/pdfbox/2.0.27/fontbox-2.0.27.jar
587744efe2a82d3584c2f3969fa4dca0
1.5 MB -
Maven build system:
https://archive.apache.org/dist/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
0e07de4a7b5c84ebed737a2002f52019
8.3 MB (additionally, about 90 MB are downloaded to the building user’s directory)
Recommended packages
- Objects for Formatting Objects (OFFO) hyphenation patterns:
https://downloads.sourceforge.net/offo/2.2/offo-hyphenation.zip
bf9c09bf05108ef9661b8f08d91c2336
862 KB
fop Dependencies
Required
Optional
a graphical environment (to run tests), JAI Image I/O Tools, and JEuclid
User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/fop
Installation of fop
Ensure $JAVA_HOME is set correctly before beginning the build. To build the JIMI SDK and/or XMLUnit extension classes, ensure the corresponding .jar files can be found via the CLASSPATH environment variable.
Installing OFFO Hyphenation Patterns
Copy the XML hyphenation patterns into the fop source tree by running the following commands:
unzip ../offo-hyphenation.zip &&
cp offo-hyphenation/hyph/* fop/hyph &&
rm -rf offo-hyphenation
Installing a temporary Maven binary
Starting with fop-2.5, the Maven build system is required. We use the binary provided by apache, that we install in a temporary location:
tar -xf ../apache-maven-3.8.6-bin.tar.gz -C /tmp
Installing fop Components
The javadoc command that ships with OpenJDK 10 and later has become much stricter than previous versions regarding conformance of the Javadoc comments in source code to HTML. The FOP documentation does not meet those standards, so the conformance checks have to be disabled. This can be done with the following command:
sed -i '\@</javad@i\
<arg value="-Xdoclint:none"/>\
<arg value="--allow-script-in-comments"/>\
<arg value="--ignore-source-errors"/>' \
fop/build.xml
The build.xml file calls for an old version of PDFBox components that are no longer available. Copy the updated PDFBox components into the source tree:
cp ../{pdf,font}box-2.0.27.jar fop/lib
Compile fop by running the following commands:
cd fop &&
LC_ALL=en_US.UTF-8 \
PATH=$PATH:/tmp/apache-maven-3.8.6/bin \
ant all javadocs &&
mv build/javadocs .
This package comes with a test suite, but the java infrastructure installed in this book does not allow running it.
Now, install Fop as the root user:
install -v -d -m755 -o root -g root /opt/fop-2.8 &&
cp -vR build conf examples fop* javadocs lib /opt/fop-2.8 &&
chmod a+x /opt/fop-2.8/fop &&
ln -v -sfn fop-2.8 /opt/fop
The last thing to do is to clean what we have done:
rm -rf /tmp/apache-maven-3.8.6
Command Explanations
sed -i … build.xml: This adds three switches to the javadoc command, preventing some errors from occurring when building the documentation.
export LC_ALL=en_US.UTF-8: the compiler fails if using an ASCII locale.
ant target: This reads the file build.xml and builds the target: compile compiles the java sources, jar-main generates jar archives, jar-hyphenation generates the hyphenation patterns for FOP, junit runs the junit tests, and javadocs builds the documentation. The all target runs all of the above.
ln -v -sf fop-2.8 /opt/fop: This is optional and creates a convenience symlink so that $FOP_HOME doesn’t have to be changed each time there’s a package version change.
Configuring fop
Config Files
~/.foprc
Configuration Information
Using fop to process some large FO’s (including the FO derived from the BLFS XML sources), can lead to memory errors. Unless you add a parameter to the java command used in the fop script you may receive messages similar to the one shown below:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
To avoid errors like this, you need to pass an extra parameter to the java command used in the fop script. This can be accomplished by creating a ~/.foprc (which is sourced by the fop script) and adding the parameter to the FOP_OPTS environment variable.
The fop script looks for a FOP_HOME environment variable to locate the fop class libraries. You can create this variable using the ~/.foprc file as well. Create a ~/.foprc file using the following commands:
cat > ~/.foprc << "EOF"
FOP_OPTS="-Xmx<RAM_Installed>m"
FOP_HOME="/opt/fop"
EOF
Replace <RAM_Installed> with a number representing the amount of RAM installed in your computer (in megabytes). An example would be FOP_OPTS="-Xmx768m".
To include the fop script in your path, update the system-wide profile with the following command as the root user:
cat > /etc/profile.d/fop.sh << "EOF"
# Begin /etc/profile.d/fop.sh
pathappend /opt/fop
# End /etc/profile.d/fop.sh
EOF
Note
Running fop can be somewhat verbose. The default logging level can be changed from INFO to any of FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, ALL, or OFF. To do this, edit $JAVA_HOME/jre/lib/logging.properties and change the entries for .level and java.util.logging.ConsoleHandler.level to the desired value.
Contents
Installed Programs: fop
Installed Libraries: fop.jar and numerous support library classes located in /opt/fop/{build,lib}; JAI components include libmlib_jai.so, jai_codec.jar, jai_core.jar, and mlibwrapper_jai.jar
Installed Directory: /opt/fop-2.8
Short Descriptions
fop is a wrapper script to the java command which sets up the fop environment and passes the required parameters.
fop.jar contains all the fop Java classes.
50.4 MuPDF-1.21.1
Introduction to MuPDF
MuPDF is a lightweight PDF and XPS viewer.
This package is known to build and work properly using an LFS 11.3 platform.
Package Information
-
Download (HTTP): https://www.mupdf.com/downloads/archive/mupdf-1.21.1-source.tar.gz
-
Download MD5 sum: 62690ebb86e3683d331554433e58c10a
-
Download size: 55 MB
-
Estimated disk space required: 249 MB
-
Estimated build time: 0.2 SBU (Using parallelism=4)
MuPDF Dependencies
Required
Recommended
HarfBuzz-7.0.0, libjpeg-turbo-2.1.5.1, OpenJPEG-2.5.0, and cURL-7.88.1
Optional
xdg-utils-1.1.3 (runtime), jbig2dec, and MuJS
Required (runtime)
User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/mupdf
Installation of MuPDF
First, fix the Makefile to link properly with the shared library:
sed -i '/MU.*_EXE. :/{
s/\(.(MUPDF_LIB)\)\(.*\)$/\2 | \1/
N
s/$/ -lmupdf -L$(OUT)/
}' Makefile
Install MuPDF by running the following commands:
cat > user.make << EOF &&
USE_SYSTEM_FREETYPE := yes
USE_SYSTEM_HARFBUZZ := yes
USE_SYSTEM_JBIG2DEC := no
USE_SYSTEM_JPEGXR := no # not used without HAVE_JPEGXR
USE_SYSTEM_LCMS2 := no # need lcms2-art fork
USE_SYSTEM_LIBJPEG := yes
USE_SYSTEM_MUJS := no # build needs source anyway
USE_SYSTEM_OPENJPEG := yes
USE_SYSTEM_ZLIB := yes
USE_SYSTEM_GLUT := no # need freeglut2-art fork
USE_SYSTEM_CURL := yes
USE_SYSTEM_GUMBO := no
EOF
export XCFLAGS=-fPIC &&
make build=release shared=yes &&
unset XCFLAGS
This package does not come with a test suite.
Now, as the root user:
make prefix=/usr \
shared=yes \
docdir=/usr/share/doc/mupdf-1.21.1 \
install &&
chmod 755 /usr/lib/libmupdf.so &&
ln -sfv mupdf-x11 /usr/bin/mupdf
Command Explanations
ln -sfv mupdf-x11 /usr/bin/mupdf : This symbolic link chooses between mupdf-gl and mupdf-x11 when running mupdf.
Contents
Installed Program: mupdf (symlink), mupdf-gl, mupdf-x11, mupdf-x11-curl, muraster, and mutool
Installed Libraries: libmupdf.so
Installed Directories: /usr/include/mupdf, /usr/share/doc/mupdf-1.21.1
Short Descriptions
mupdf is a program for viewing PDF, XPS, EPUB, and CBZ documents, and various image formats such as PNG, JPEG, GIFF, and TIFF.
mupdf-gl same as mupdf, using an opengl renderer.
mupdf-x11 same as mupdf, using an X Window renderer.
muraster is a program used to perform rasterization tasks with PDF documents.
mutool is a program to perform various operations on PDF files, such as merging and cleaning PDF documents.
libmupdf.so contains the mupdf API functions.
50.5 paps-0.7.1
Introduction to paps
paps is a text to PostScript converter that works through Pango. Its input is a UTF-8 encoded text file and it outputs vectorized PostScript. It may be used for printing any complex script supported by Pango.
This package is known to build and work properly using an LFS 11.3 platform.
Package Information
-
Download (HTTP): https://downloads.sourceforge.net/paps/paps-0.7.1.tar.gz
-
Download MD5 sum: b058bcc7d958fb53408942088cc1f365
-
Download size: 140 KB
-
Estimated disk space required: 1 MB
-
Estimated build time: less than 0.1 SBU
paps Dependencies
Required
Optional
User Notes: https://wiki.linuxfromscratch.org/blfs/wiki/Paps
Installation of paps
Install paps by running the following commands:
./configure --prefix=/usr --mandir=/usr/share/man &&
make
This package does not come with a test suite.
Now, as the root user:
make install
Contents
Installed Program: paps
Installed Library: None
Installed Directory: None
Short Descriptions
paps is a text to PostScript converter that supports UTF-8 character encoding.