Prince
  • Buy Prince
  • Samples
  • Documentation
  • Forum
  • Download
  • Installation Guide
  • User Guide
  • Reference Guide

Contents

  • 1. Getting Started
    • Installing Prince
      • Installing Prince on Windows
      • Installing Prince on MacOS X
      • Installing Prince on Linux
        • Debian and Ubuntu
        • Redhat and CentOS
        • OpenSUSE
        • FreeBSD, Solaris and Generic Linux
      • Installing a license file
      • Installation Layout
        • Windows installation layout
        • MacOS X installation layout
        • Linux installation layout
    • Your First Document
      • The lab report
      • Processing the document
      • Styling the document
  • 2. Styling
    • Fonts
      • Defining a font family
      • Generic font families
      • OpenType Features in Prince
      • Redefining the generic font families
    • Layout
      • Text formatting
      • Paragraph formatting
      • Writing Mode
      • CSS Box Model
        • Margin
        • Padding
        • Border
        • Background
      • Tables
        • Automatic table layout
        • Fixed table layout
        • Separated table borders
        • Collapsing table borders
        • Cells that span columns
        • Cells that span rows
        • Numbering table rows
        • Running table headers and footers
        • Table captions
      • Lists
        • List marker position
        • List marker type
        • List marker style
      • Columns
      • Floats
        • Prince extensions to floats
      • Footnotes
        • Footnote calls
        • Footnote markers
        • Styling footnotes
    • Paged Media
      • Page size
      • Page style
      • Trimming marks
      • Page regions
        • Generated content in page regions
      • Selecting pages
        • Blank pages
      • Controlling pagination
        • Page breaks
        • Widows and orphans
  • 3. Scripting
    • JavaScript in Printed Media
    • Logging
    • Console access
    • Event handling
    • Document statistics
    • PDF properties
    • Unsupported DOM properties
  • 4. Graphics
    • Color
      • RGB
      • RGBA
      • CMYK
      • Spot colors
    • Color Management
      • Introduction
      • Color Management and PDF Profiles
      • Color Management in Prince
      • Color conversion
      • Rich black and true black
      • Page color space
    • Filters
    • Images
      • Images in XHTML
      • Images in DocBook
      • Images in Arbitrary XML
      • CSS and Images
        • Image Size in Print
    • Scalable Vector Graphics (SVG)
      • Viewbox and viewport
      • Rectangles
      • Circles
      • Ellipses
      • Lines
      • Masks
      • Polylines
      • Polygons
      • Paths
      • Text
      • Images
      • Links
      • Transformations
      • Style Properties
    • Rasterization
  • 5. Prince Tips and Tricks
    • Generated Content
      • Page headers and footers
      • List markers
      • Footnote markers
      • Before and After pseudo-elements
      • Counters and Numbering
        • Counter reset and increment
        • Nested counters
        • Counter styles
      • Cross-references
        • Using target-counter
        • Using target-content
      • Script Functions
        • Accessing the current date and time
        • User-defined counter styles
      • Using generated content in page regions
      • Copying text content from the document
      • Taking elements from the document
    • Advanced paged media examples
      • Named pages
      • Page groups
      • Page breaks and decoration
      • Printing wide content sideways
    • Hyphenation
    • Typographic Ligatures
    • Watermarks
    • Rotating content in table cells
    • The "Two-Pass" Solution
  • 6. Help
    • Troubleshooting
      • Missing glyphs or fonts
      • Fontconfig
      • Image formats
      • Shared library trouble
      • PATH issues
      • The capture/replay system
      • Running the debug script
    • Frequently Asked Questions
  • 7. Prince Input
    • Applying Style Sheets in Prince
      • Importing Style Sheets
      • Conflicting Declarations
      • Priority Determination
    • Applying JavaScript in Prince
    • XML Input
      • XML Input
        • Validation
        • xml:lang
        • xml:id
        • xml:base
      • XML Styling
      • XML Inclusions (XInclude)
        • Including XML files
        • Including text files
        • Fallback
  • 8. Prince Output
    • PDF Profiles
      • PDF/A
      • PDF/X
    • PDF Output Options
      • PDF Links
      • PDF Actions
      • PDF Pages
      • PDF Printing
      • PDF Compression
      • Font Embedding
      • Creating PostScript output
    • PDF Bookmarks
      • Bookmark levels
      • Bookmark labels
      • Bookmark targets
    • PDF Metadata
      • XMP Metadata
  • 9. Server Integration
    • Security and performance
    • Prince Wrappers
      • Third-Party Wrappers
      • Using Prince from Java
      • Using Prince from .NET with C#
      • Using Prince from .NET with VB.NET
      • Using Prince from Python
      • Using Prince from Perl
      • Using Prince from PHP
      • Using Prince from ASP
      • Using Prince from ColdFusion
      • Using Java
      • Using ActiveX/COM
      • Using Prince from ActiveX / COM / Visual Basic
    • Advanced Command Line Options
      • Prince Control Protocol
      • Structured Log

Reference Guide

  • A1. Command-line Reference
    • Examples
    • Specifying input and output
    • Options
      • General Options
      • Logging Options
      • Input Options
      • Network Options
      • JavaScript Options
      • CSS Options
      • PDF Output Options
      • PDF Metadata Options
      • PDF Encryption Options
      • Raster Output Options
      • Utility Options
      • Advanced Control and Log Options
  • A2. CSS References
    • CSS Features
    • Length Units
      • Absolute Length Units
      • Font Length Units
      • Pixel Unit
  • A3. CSS Properties
    • alternate-color
    • background
    • background-attachment
    • background-clip
    • background-color
    • background-image
    • background-origin
    • background-position
    • background-repeat
    • background-size
    • baseline-shift
    • border
    • border-bottom
    • border-bottom-color
    • border-bottom-left-radius
    • border-bottom-right-radius
    • border-bottom-style
    • border-bottom-width
    • border-clip
    • border-collapse
    • border-color
    • border-left
    • border-left-color
    • border-left-style
    • border-left-width
    • border-radius
    • border-right
    • border-right-color
    • border-right-style
    • border-right-width
    • border-spacing
    • border-style
    • border-top
    • border-top-color
    • border-top-left-radius
    • border-top-right-radius
    • border-top-style
    • border-top-width
    • border-width
    • bottom
    • box-decoration-break
    • box-sizing
    • caption-side
    • clear
    • clip
    • clip-path
    • clip-rule
    • color
    • column-break-after
    • column-break-before
    • column-count
    • column-fill
    • column-gap
    • column-rule
    • column-rule-color
    • column-rule-style
    • column-rule-width
    • column-span
    • column-width
    • columns
    • content
    • counter-increment
    • counter-reset
    • direction
    • display
    • dominant-baseline
    • empty-cells
    • fill
    • fill-opacity
    • fill-rule
    • filter
    • float
    • font
    • font-family
    • font-size
    • font-stretch
    • font-style
    • font-variant
    • font-weight
    • footnote-display
    • footnote-style-position
    • height
    • hyphens
    • left
    • letter-spacing
    • line-height
    • line-stacking-strategy
    • list-style
    • list-style-image
    • list-style-position
    • list-style-type
    • margin
    • margin-bottom
    • margin-inside
    • margin-left
    • margin-outside
    • margin-right
    • margin-top
    • marker-end
    • marker-mid
    • marker-start
    • marks
    • mask
    • max-height
    • max-width
    • min-height
    • min-width
    • opacity
    • orphans
    • overflow
    • overflow-wrap
    • padding
    • padding-bottom
    • padding-left
    • padding-right
    • padding-top
    • page
    • page-break-after
    • page-break-before
    • page-break-inside
    • position
    • prince-background-image-resolution
    • prince-bleed
    • prince-bookmark-label
    • prince-bookmark-level
    • prince-bookmark-state
    • prince-bookmark-target
    • prince-caption-page
    • prince-fallback-cmyk-profile
    • prince-filter-resolution
    • prince-flow
    • prince-footnote-policy
    • prince-forced-breaks
    • prince-hyphenate-after
    • prince-hyphenate-before
    • prince-hyphenate-character
    • prince-hyphenate-lines
    • prince-hyphenate-patterns
    • prince-image-magic
    • prince-image-resolution
    • prince-linebreak-magic
    • prince-link
    • prince-mark-length
    • prince-mark-offset
    • prince-mark-width
    • prince-page-group
    • prince-pdf-color-conversion
    • prince-pdf-color-options
    • prince-pdf-destination
    • prince-pdf-duplex
    • prince-pdf-link-type
    • prince-pdf-open-action
    • prince-pdf-output-intent
    • prince-pdf-page-colorspace
    • prince-pdf-page-label
    • prince-pdf-page-layout
    • prince-pdf-page-mode
    • prince-pdf-paper-tray
    • prince-pdf-print-scaling
    • prince-pdf-profile
    • prince-pdf-script
    • prince-pdf-xmp
    • prince-rotate-body
    • prince-shrink-to-fit
    • prince-text-justify
    • prince-text-replace
    • prince-tooltip
    • prince-trim
    • prince-wrap-inside
    • right
    • size
    • src
    • stop-color
    • stop-opacity
    • string-set
    • stroke
    • stroke-dasharray
    • stroke-dashoffset
    • stroke-linecap
    • stroke-linejoin
    • stroke-miterlimit
    • stroke-opacity
    • stroke-width
    • table-baseline
    • table-column-span
    • table-layout
    • table-row-span
    • text-align
    • text-align-last
    • text-anchor
    • text-decoration
    • text-indent
    • text-line-through
    • text-line-through-color
    • text-line-through-style
    • text-overflow
    • text-overline
    • text-overline-color
    • text-overline-style
    • text-transform
    • text-underline
    • text-underline-color
    • text-underline-style
    • top
    • transform
    • transform-origin
    • unicode-bidi
    • unicode-range
    • vertical-align
    • visibility
    • white-space
    • widows
    • width
    • word-break
    • word-spacing
    • writing-mode
    • z-index
  • A4. CSS Selectors
    • Terminology and Definitions
    • Logical Combinations
    • Elemental Selectors
    • Attribute Selectors
    • Linguistic Pseudo-classes
    • Location Pseudo-classes
    • Tree-Structural pseudo-classes
    • Combinators
    • Tree-Abiding Pseudo-element Selectors
    • Typographic Pseudo-element Selectors
    • Footnote Pseudo-element Selectors
    • Page Selectors
  • A5. CSS Media Queries
    • Media Queries
    • Media Query Modifiers
    • Media Types
    • Media Features
    • Dimension Media Features
    • Display Quality Media Features
    • Color Media Features
    • Interaction Media Features
    • Scripting Media Features
  • A6. CSS Functional Expressions
    • CSS Functions
    • Prince Specific Functions
  • A7. CSS At-rules
    • Initial At-Rules
    • Nested At-Rules
  • A8. Page Size Keywords
  • A9. Character Entities
    • Accented Letters
    • Symbols
    • Quotes
    • Accents
    • Miscellaneous
  • A10. Acknowledgements

Prince Tips and Tricks

Generated Content

Generated content is text and other content that is not found in the original input document, but is added to the output from a style sheet using the CSS content property.

Page headers and footers

The content property can be applied to page regions, such as @top and @bottom, to create page headers and footers with generated content. See Page regions for more details.

CSS

@page {
    @top { content: "Prince User Guide" }
    @bottom { content: counter(page) }
}

List markers

The content property can be applied to the ::marker pseudo-element to specify a custom marker for list items. See Lists for more details.

CSS

li::marker { content: "No. " counter(list-item) }

Footnote markers

The content property can be applied to the ::footnote-call and ::footnote-marker pseudo-elements to specify custom markers for footnotes. See Footnotes for more details.

CSS

.fn::footnote-call { content: "*" }

Before and After pseudo-elements

The content property can be applied to the ::before and ::after pseudo-elements to add generated content before or after an element. For example, adding section numbers in front of headings or including quotation marks around a block of text.

CSS

h1::before, h1::after { content: "***" }

This will place three asterisks before and after h1 elements.

Counters and Numbering

Counters are the mechanism provided by CSS to perform numbering. They can be used to number list items, pages, footnotes, sections and any other document content that needs to be numbered.

Counter reset and increment

The counter-reset property applies to any element and initialises one or more counters to the specified values, or to zero if no value is specified.

Unless the resetting of a counter creates a nested counter, the scope of the counter includes the current element and all of its following siblings.

The counter-increment property applies to any element and increments one or more counters by the specified values, or by one if no value is specified.

The counter-increment and counter-reset properties are ignored on elements whose display property has the value none.

CSS

div.example1 { counter-reset: h3 h4 }
div.example1 h3 { counter-increment: h3 }
div.example1 h4 { counter-increment: h4 }
div.example1 h3::before { content: counter(h3) }
div.example1 h4::before {
    content: counter(h4, lower-alpha)
}

This creates two counters inside the scope of a div element. All h3 and h4 heading elements will be numbered starting from 1 and the counter number will be placed before the heading text.

CSS

div.example2 { counter-reset: h3 }
div.example2 h3 {
    counter-increment: h3;
    counter-reset: h4
}
div.example2 h4 { counter-increment: h4 }
div.example2 h3::before { content: counter(h3) }
div.example2 h4::before {
    counter(h4, lower-alpha)
}

In this example the h4 counter will be reset at each h3 element, to produce sub-section numbering that restarts at each new section.

Nested counters

If a counter is reset on an element and the same counter has also been reset on an ancestor of that element, a nested counter will be created. The scope of the nested counter is the current element only and its final value will not be carried onto its following siblings.

For example, a nested XHTML list with a ul element inside a li inside another ul creates a nested list-item counter.

CSS

ol { counter-reset: list-item }
li { counter-increment: list-item }
li::marker {
    content: counters(list-item, ".", decimal);
    color: brown;
    font-weight: bold
}

Counter styles

Counter values are displayed as decimal numbers by default, but they may be displayed using other styles such as roman numerals or consecutive letters of the alphabet.

CSS

chapter { counter-increment: chapter-num }

chapter::before {
    content: "Chapter " counter(chapter-num, upper-roman)
}

This rule will generate text such as "Chapter IV" before each chapter, with the appropriate chapter number displayed in uppercase roman numerals.

The following table shows examples of the various counter styles:

decimal 1, 2, 3, … 9, 10, 11, …
decimal-leading-zero 01, 02, 03, … 09, 10, 11, …
lower-roman i, ii, iii, iv, v, vi, …
upper-roman I, II, III, IV, V, VI, …
lower-alpha, lower-latin a, b, c, … z, aa, ab, …
upper-alpha, upper-latin A, B, C, … Z, AA, AB, …
asterisks *, **, ***, ****, …
lower-hexadecimal 1, 2, 3, … 9, a, b, c, …
upper-hexadecimal 1, 2, 3, … 9, A, B, C, …
octal 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, …
binary 1, 10, 11, 100, 101, 110, 111, …
arabic-indic ١, ٢, ٣, ٤, ٥, ٦, …
persian / urdu ۱, ۲, ۳, ۴, ۵, ۶, …
cjk-decimal 一, 二, 三, 四, 五, 六, …
japanese-informal 一, 二, 三, 四, 五, 六, …
simp-chinese-informal 一, 二, 三, 四, 五, 六, …
trad-chinese-informal 一, 二, 三, 四, 五, 六, …
japanese-formal 壱, 弐, 参, 四, 五, 六, …
simp-chinese-formal 壹, 贰, 叁, 肆, 伍, 陆, …
trad-chinese-formal 壹, 貳, 參, 肆, 伍, 陸, …
lower-norwegian a, b, c, … z, æ, ø, å, aa, ab, …
upper-norwegian A, B, C, … Z, Æ, Ø, Å, AA, AB, …
lower-russian а, б, в, г, д, е, ж, …
upper-russian А, Б, В, Г, Д, Е, Ж, …
lower-ukranian а, б, в, г, д, е, є, …
upper-ukranian А, Б, В, Г, Д, Е, Є, …
lower-belarusian а, б, в, г, д, е, ж, …
upper-belarusian А, Б, В, Г, Д, Е, Ж, …
lower-bulgarian а, б, в, г, д, е, ж, …
upper-bulgarian А, Б, В, Г, Д, Е, Ж, …
lower-serbian а, б, в, г, д, ђ, е, …
upper-serbian А, Б, В, Г, Д, Ђ, Е, …
repeat(x, y, z) x, y, z, xx, yy, zz, xxx, yyy, …
symbols(x, y, z) x, y, z, 4, 5, 6, …

Cross-references

Prince supports cross-references using generated content with two special functions: target-counter and target-content.

Using target-counter

The target-counter function can be used with the content property to reference the value of a counter at a linked element.

CSS

a[href]::after {
    content: " [See page " target-counter(attr(href), page) "]"
}

This will add a cross-reference after every link with the correct page number determined automatically. For example: [See page 17].

The target-counter function can specify any counter, allowing cross-references to refer to list items, chapters or sections as well as pages.

The target-counter function can also take an optional counter style, similar to the normal counter function.

CSS

a[href]::after {
    content: " [See chapter "
	     target-counter(attr(href), chapter, upper-roman)
	     "]"
}

This will add a cross-reference after every link with the correct chapter number determined automatically and displayed using roman numerals. For example: [See chapter IV].

Using target-content

The target-content function can be used with the content property to reference the text content of a linked element.

CSS

a[href]::after {
    content: " [See '" target-content(attr(href)) "']"
}

This will add a cross-reference after every link that includes the text of the element being linked to, such as a chapter title. For example: [See 'Introduction'].

Script Functions

Prince supports arbitrary JavaScript functions to be called from CSS generated content using the prince-script() function (see the content property).

Please note that Prince is not running JavaScript by default - it needs to be explicitly enabled. See Applying JavaScript in Prince.

CSS

p::after {
    content: prince-script(myfunc)
}

JavaScript

function myfunc()
{
    return "Some generated content text!";
}

Prince.addScriptFunc("myfunc", myfunc);

Accessing the current date and time

JavaScript functions have access to the current date and time, which can be added to the document using prince-script() in generated content.

CSS

@page {
    @top {
	content: prince-script(datestamp)
    }
}

JavaScript

Prince.addScriptFunc("datestamp", function() {
    return (new Date()).toString();
});

User-defined counter styles

The JavaScript functions used with prince-script() can take arguments that are themselves generated content. This allows functions to operate on counter values and implement new counter styles.

CSS

li::marker {
    content: prince-script(mycounterstyle, counter(list-item))
}

JavaScript

Prince.addScriptFunc("mycounterstyle", function(n) {
    if (n == 1) return "one";
    else if (n == 2) return "two";
    else if (n == 3) return "three";
    else return n;
});

Using generated content in page regions

Generated content in page regions may contain text, page numbers or text content copied from the document.

CSS

@page {
    @top-left {
        content: "TOP SECRET";
        color: red
    }
    @bottom-right {
        content: counter(page);
        font-style: italic
    }
}

The @page rule specifies that the top-left page region will contain the text "TOP SECRET" in red and the bottom-right page region will contain the current page number in an italic font.

Copying text content from the document

Generated content in page regions may also contain text content copied from the document using the string-set property:

CSS

@page {
    @top {
        content: string(doctitle)
    }
}

h1 { string-set: doctitle content() }

The @page rule specifies that the top-center page region will contain the text content of the document title copied from the text content of the h1 element in the document.

The second argument to the string() function is a page-policy, which can be one of the following: first (the first value the string is set to on the page), first-except (equivalent to start unless the string-set is applied on the current page, in which case it will return no value), last (the last value the string is set to on the page) or start (the value the strin has at the start of the page).

For a dictionary, you might want to have a page header that says "a-af", where "a" is the first definition on the page and "af" is the last, so you apply string-set for each definition, and then you can select the first and last in the header.

The value first-except is equivalent to start, unless the string-set is applied on the current page, in which case it will return no value.

These values of page-policy are used in the Dictionary sample (HTML - PDF).

Taking elements from the document

Page region content may be taken from the document itself. Any block-level element can be removed from the normal flow and placed in a page region.

CSS

@page {
    @top { content: flow(header) }
}
h1 { flow: static(header) }

The @page rule specifies that the top page region is a new static flow named "header".

The rule for the h1 element moves it to the "header" static flow, removing it from the default normal flow.

Please note that:

  • All margin properties of a non-normal flow element will be ignored.
  • The first non-normal flow element that appears on a page will be used on the current page and carried onto following pages.
Copyright © 2002 – 2019 YesLogic Pty. Ltd.
  • About Us
  • Privacy Policy
  • Contact Us