Prince is a computer program that converts HTML and XML to PDF documents. It is simple, yet very powerful, and it creates beautiful documents with rich CSS formatting. Prince 7 adds important new features in the areas of internationalization, fonts, and line-breaking. In this document, we showcase new features along with some of our favorites from the past. This document is written in HTML and converted to PDF by Prince. The source is a tiny 14k file.
Prince 7 adds many internationalization features. It has a new shaping engine which allows different languages and scripts to be combined in the same document. For example, Arabic (العربية) and Hebrew (עִבְרִית) are written from right to left. When combined with English (as in the previous sentence) the formatter must support bi-directional text. Prince 7 supports the Unicode bidi-algorithm, the CSS «direction» and «unicode-bidi» properties, and the HTML «dir» attribute and «bdo» element.
Prince 7 can also do case shifting in different scripts. The Russian word for «Prince» is Принц. In uppcase it is written Принц.
Dividing a paragraph into lines of text is a visual problem with a mathematical solution. Prince 7 implements the Knuth-Plass algorithm for optimized line-breaking. The algorithm devised by Donald KnuthDonald Knuth is, perhaps, better known for having developed TEX, a formatting system from which CSS borrows liberally. and Michael Plass considers all possible breakpoints in a paragraph, and finds the best-looking combination of line breaks.
Prince can replace characters without changing the source document. For example, notice how Prince has replaced the apostrophes with a quotation mark here: it's. This feature is called character substitution.
Some of the fonts used in this document are Web fonts. Prince can fetch fonts from the web and use them without installing them on your system. Also, Prince 7.1 supports the emerging WOFF web font format. Here is a small example of an OpenType font (Megalopolis) that has been converted to WOFF, published on the web, and fetched on demand by Prince 7.1:
In printing, crop marks are used to indicate where the printed paper should be cut, while cross marks are used to align prints of different colors to improve color reproduction. Prince adds support for crop and cross marks, and the PDF version of this document includes both.
Printers don't use RGB colors, they mostly use CMYK colors: cyan, magenta, yellow and black. Prince can read CMYK colors and will use them, if present. The background color of the box on top of this paragraph has both RGB (redish) and CMYK (bluish) colors specified. Therefore, the box is red in browsers, but blue in the PDF version.
Prince can read hyperlinks inside a document and generate page numbers accordingly. For example, it will automatically find out which page Headers and Footers are discussed on (page). Cross-references are used to generate the Table of contents (page).
Leaders consist of dots or dashes in a row leading the eye across a page. For example, the Table of contents has leaders in it. The leaders are not found in the document itself, but rather in the style sheet.
Scalable Vector Graphics (SVG) is a language for describing two-dimensional graphics for the web. SVG images scale better than traditional bitmapped images and are suitable for printing. The crown at the bottom of this page is an SVG image from Wikimedia.
Printed documents often have page headers and footers. For example, page numbers are often printed at the bottom of the page, and the document title is shown at the top – except on title pages.
FootnotesA footnote is a note placed at the bottom of a page of a book or manuscript that comments on or cites a reference for a designated part of the text. are essential in printed documents and Prince knows how to generate them. Unlike what some people think, footnotes are not the place to put information you don't want to see. More often, footnotes will actually attract attention. 9 of 10 of readers will read the footnotes before they read the text from where the footnotes are anchored.Often, the most interesting information is found in the footnotes.
Prince will automatically generate PDF bookmarks from heading elements in HTML. The feature is set with a property in the style sheet, and can also be used with other markup languages.