Basics

Definition of a Multiplexed Document

RFC3391 - The MIME Application/Vnd.pwg-multiplexed Content-type
is used by XHTML-Print
as a file format to use when bundling an XHTML-Print document and its associate
image and style sheet files into a single, compound document. The
app_multiplexed utility creates such a compound document interleaving or
multiplexing image and style sheet files with the XHTML-Print document
that references it.

The compound document produced by app_multiplexed conforms to the RFC3391:

Following the format of MIME headers, the file starts with a Content-Type header:

The document is composed of messages, which are the entities representing the XHTML-Print document
and the images and styles sheets it references.

Each message is divided into one or more chunks, where a chunk
is a composed of:

a MIME formatted chunk header, containing, at a minimum:

A "CHK" keyword followed by

the message number,

the chunk payload length,

whether the chunk is the last chunk of a message and, finally,

a CRLF

a chunk payload that contains all or part of the message, and

a Carriage Return/Line Feed to provide visual separation between the chunks

The chunks that make up a message must appear in order of the original
message content. However,
chunks of different messages can be interleaved. This allows the placement
of an image directly after the reference to it, thus reducing the buffered
needed to print the document.

The first chunk in the document must be from
the message containing the XHTML-Print document.

The last chunk of the document must be a chunk with the following chunk header and an empty payload

CHK 0 0 LAST

The relationship between messages is indicated by use of either
Content-Location or Content-ID header. For example, the XHTML-Print document may
reference an image whose URI is "image.jpg" in a img or object element and the
chunk for the message containing the image can have a Content-Location header
containing "image.jpg".

A simple example

The following is a simple XHTML-Print document that prints a single page with
the words "Hello world!":

The multiplexed document version of this example, contains two messages: the xhtml-print document
(Message 1) and the image, tests/image.jpg (Message 2). The both
messages are divided into two chunks and interleaved.

The diagram on the right illustrates how the two messages contribute to
making the single, compound, multiplexed document that starts with the required
Content-Type header and the first chunk of the first message.

The first chunk of the second message follows directly after the reference to
it in the first message, which causes the division of the first message into two
chunks.

The second message contains the JPEG image, so it is divided into two chunks.
The first chunk contains the image header, which provides enough immediate
information so that the page can be laid out. The second chunk contains
the image data approximately at the end of the page, so that it is available as
the printer needs it and not before.

The document ends with the required empty chunk for message zero.

The multiplexed document below is constructed from the XHTML-Print document
in this example:

Interleaving Multiple Images

When a document references multiple images, each image is a separate message
divided into two chunks: the first chunk containing the image header, the second
the image data. Each image header chunk follows directly after an image
reference in the XHTML-Print document. The image data chucks are collected a
placed in the document at approximately where the printer will need them when
printing the page.

How app_multiplexed works

The app_multiplexed utility :

reads an XHTML-Print document,

collects referenced entities and

combines them into a multiplexed document.

Reading an XHTML-Print document

This processing involves looking for URI's in the attributes of
the img and object elements, as well as the url function within style sheets and
style attributes. For example:

<img src="image.jpg" ... />

<object data="image.jpg" ... >

<p style="background-image: url(image.jpg)" ... >

<style type="text/css"> p {background-image: url(image.jpg)} ...

Features

Creating a multiplexed document

The simplest way to create a multiplexed file is by invoking app_multiplexed
from the command line with the name of a file containing an XHTML-Print document:

bash-2.04$ app_multiplexed helloworld.htm > helloworld.mx

In this situation app_multiplexed accepts one file that is assumed to contain
an XHTML-Print document, scans the document for URIs, attempts to collect the
referenced entities, constructs the multiplexed document and writes it to
standard out.

Help

The man page below is the current source of help for this utility.

Man Page

app_multiplexed(1)

name

app_multiplexed - creates a multiplexed document from an XHTML-Print document

synopsis

app_multiplexed [OPTION]... [-] [FILE] ...

description

Reads FILE(s) and their associated resources (either images or style sheets)
and by writes a multiplexed file to standard out when a single input file is
specified on the command line. If multiple files are given, app_multiplexed writes a multiplexed
file for each input file using either the default file suffix, "mx" or the
suffix given by the -output-prefix option at the end of the input file name.
For example, "app_multiplexed doc1.htm doc2.htm" results in doc1.htm.mx and
doc2.htm.mx.

If no files are given on the command line, then input is taken from standard in
and the multiplexed file is written to standard out. For example,
"cat doc.htm | app_multiplexed | lp"

Command Line Options

-base

Defines the base to use when resolving relative URIs.

-encode

Encodes MIME headers as required by RFC 2047 and RFC 1738. Also performs
folding of field bodies longer than 40 characters.

-content-disp="value"

Adds a Content-Disposition="value" header to each chunk.

-cid

Adds a Content-ID header to each chunk

-reusemsg

Reuses message numbers of message that are complete. For example give
a two page document that a difference image on each page, the document will be
message "1", the image on the first page is message "2". If all the chunks of
message "2" occur before the first chunk of the image on the second page, then
when this option is used, the message number of the second image is "2" rather
than "3".

-force-before-root

Arranges message chunks so that image headers are before the document and
image data after the document.

-output-prefix

Sets the file suffix to use when writing multiplexed documents to a file
rather than standard out. The default suffix is "mx".

-interleave="list"

Interleaves the chunks of the images in the given, comma separated list.
For example, "app_multiplexed.exe -interleave="tests/image.jpg,image.jpg"
imgref.htm" creates a multiplexed document where the data of the images named in
the value of -interleave, are divided into multiple chunks and the chunks of the
two messages are interleaved.

Copyright (c) 2004 Hewlett-Packard Development Company,
L.P.Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice
and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.