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

Scalable Vector Graphics (SVG)

SVG can be included in any XML document simply by adding a svg element.

Global definitions of graphical elements are supported, for example references to elements outside of the current SVG fragment, either in the same document or other documents. Defining these elements in a <defs> element helps understandability of the SVG element. You can use a <use> element to reference those elements later.

The display, float, and flow properties and all margin, padding, border, and background properties can be applied to the top-level svg element but not to child elements within it.

The following elements are supported inside the svg element:

g for grouping related graphics elements
rect for drawing rectangles
circle for drawing circles
ellipse for drawing ellipses
line for drawing lines
mask for masking another element
polyline for drawing polylines
polygon for drawing polygons
path for drawing arbitrary paths
text for drawing text
tspan for adjusting text and font properties inside the text element
image for including bitmap image files
a for creating hyperlinks
defs for containing referenced elements
use for using a referenced element

Viewbox and viewport

The svg element should include view box and view port information so that the SVG content can be correctly mapped to the containing box.

Attributes
width the width of the viewport (100% of the container width, if omitted)
height the height of the viewport (100% of the container width, if omitted)
viewBox(x y width height) the x, y coordinate of the top left corner of the viewbox and the width and height of the viewbox

XML

<svg width="3cm" height="2cm" viewBox="0 0 300 200">
    <!-- the SVG content -->
</svg>

Rectangles

Rectangles are created using the rect element.

Attributes
x, y the x, y coordinates of the top left corner of the rectangle
width the width of the rectangle
height the height of the rectangle
rx, ry the radii for rounded corners

XML

<svg viewBox="0 0 500 300"
        width="10cm" height="6cm">
 <g fill="none" stroke="gray" stroke-width="20">
  <rect x="50" y="50" width="400" height="200"
        rx="80" ry="50"/>
 </g>
</svg>

Output

Rect example

Circles

Circles are created using the circle element.

Attributes
cx, cy the centre of the circle
r the radius of the circle

XML

<svg viewBox="0 0 200 200"
        width="5cm" height="5cm">
 <g fill="none" stroke="gray" stroke-width="20">
   <circle cx="100" cy="100" r="100"/>
 </g>
</svg>

Output

Circle example

Ellipses

Ellipses are created using the ellipse element.

Attributes
cx, cy the centre of the ellipse
rx, ry the radii of the ellipse

XML

<svg viewBox="-10 0 220 200"
        width="6cm" height="6cm">
 <g fill="none" stroke="gray" stroke-width="20">
  <ellipse cx="100" cy="100" rx="100" ry="60" />
 </g>
</svg>

Output

Ellipse example

Lines

Lines are created using the line element.

Attributes
x1, y1 the start point of the line
x2, y2 the end point of the line

XML

<svg viewBox="0 0 100 50"
        width="6cm" height="3cm">
 <g stroke="gray" stroke-width="2">
    <line x1="10" y1="25" x2="90" y2="25"/>
 </g>
</svg>

Output

Line example

Masks

Masks are created using the mask element.

Attributes
x the x-axis coordinate of one corner of the rectangle
y the y-axis coordinate of one corner of the rectangle
width the width of the rectangle
height the height of the rectangle

XML

<svg xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <linearGradient id="Gradient">
      <stop offset="0" stop-color="white" stop-opacity="0" />
      <stop offset="1" stop-color="white" stop-opacity="1" />
    </linearGradient>
    <mask id="Mask" x="0" y="0" width="200" height="200">
      <rect x="0" y="0" width="200" height="200" fill="url(#Gradient)"  />
    </mask>
  </defs>

  <rect x="0" y="0" width="200" height="200" fill="green" />
  <rect x="0" y="0" width="200" height="200" fill="red" mask="url(#Mask)" />
</svg>

Output

Mask example

Polylines

Polylines are created using the polyline element.

Attributes
points list of points that defines the line. Points are separated by whitespace and each point is a pair of x, y coordinates separated by comma.

XML

<svg viewBox="0 0 600 400"
        width="6cm" height="4cm">
 <g stroke="gray" stroke-width="10">
  <polyline points="50,300 200,300 200,100
               400,100 400,300 550,300" />
 </g>
</svg>

Output

Polyline example

Polygons

Polygons are created using the polygon element.

Attributes
points list of points that defines the line. Points are separated by whitespace and each point is a pair of x, y coordinates separated by comma.

XML

<svg viewBox="600 0 600 400"
        width="6cm" height="4cm">
 <g fill="none" stroke="gray" stroke-width="10">
    <polygon points="850,75  958,137.5 958,262.5
                    850,325 742,262.6 742,137.5" />
 </g>
</svg>

Output

Polygon example

Paths

The path element is for drawing arbitrary paths. The d attribute inside the element path takes a list of path commands. Parameters of a command can be separated either by whitespace or a comma.

Command Parameters Meaning
M (absolute), m (relative) (x y)+ moves to the given (x, y) coordinates to start a new subpath
Z or z none closes the current subpath
L (absolute), l (relative) (x y)+ draws a line to the given (x, y) coordinates
H (absolute), h (relative) x+ draws a horizontal line to the given x coordinates
V (absolute), v (relative) y+ draws a vertical line to the given y coordinates
C (absolute), c (relative) (x1 y1 x2 y2 x y)+ draws a cubic Bézier curve to the given (x,y) coordinates, uses the given (x1,y1) coordinates as the first control point, the (x2,y2) coordinates as the second control point
S (absolute), s (relative) (x2 y2 x y)+ short hand of the C/c command: the reflection relative to the current point of the second control point of the previous command is used as the first control point.
Q (absolute), q (relative) (x1 y1 x y)+ draws a quadratic cubic Bézier curve to the given (x,y) coordinates, uses the given (x1,y1) coordinates as the control point.
T (absolute), t (relative) (x y)+ short hand of the Q/q command: the reflection relative to the current point of the control point of the previous command is used as the control point.
A (absolute), a (relative) (rx ry x-axis-rotation large-arc-flag sweep-flag x y)+ draws an elliptical arc to (x, y): the size and rotation of the ellipse are defined by two radii (rx, ry) and the x-axis-rotation; the center (cx, cy) of the ellipse is also determined by the large-arc-flag and sweep-flag constraint.

XML

<svg viewBox="0 0 600 400"
        width="12cm" height="8cm">
 <g fill="none" stroke="red" stroke-width="10">
    <path d="M100,200 C100,100 250,100
		    250,200 S400,300 400,200" />
 </g>
</svg>

Output

Path example

Text

The text element is for writing arbitrary text. The tspan element is supported inside the text element, for adjusting text position and font properties.

Attributes
x, y the absolute position of the text
dx, dy the relative offset of the current text position (optional)

XML

<svg viewBox="0 0 1000 300"
        width="10cm" height="3cm">
    <text x="200" y="150" fill="blue" font-size="70">
      That
        <tspan dx="2em" dy="-50" font-weight="bold" fill="red" >
          is
        </tspan>
        <tspan dy="100">
           a peach!
        </tspan>
    </text>
</svg>

Output

Text example

Images

The image element is for including external image files, either bitmap images or other SVG images.

Attributes
xlink:href the URL of the image to include
x, y the x, y coordinates of the top left corner of the image
width the width of the image
height the height of the image

Note that the href element must be placed in the XLink namespace: http://www.w3.org/1999/xlink in order to work.

XML

<svg xmlns:xlink="http://www.w3.org/1999/xlink"
    ...
    <image x="100" y="100" width="50" height="50" xlink:href="myimage.jpg"/>
    ...
</svg>

Links

The a element is for creating hyperlinks.

Attributes
xlink:href the URL of the link

Note that the href element must be placed in the XLink namespace: http://www.w3.org/1999/xlink in order to work.

XML

<svg xmlns:xlink="http://www.w3.org/1999/xlink"
    ...
    <a xlink:href="http://www.example.com">
        ...
    </a>
    ...
</svg>

Transformations

The transform attribute can be used on g, path, and all of the basic shape elements. It accepts any sequence of the following transformations separated by whitespace.

  • translate(tx ty)
  • scale(sx [sy])
  • rotate(angle)
  • skewX(angle)
  • skewY(angle)
  • matrix(a b c d e f)

XML

<svg viewBox="-150 -200 1400 700" width="12cm" height="6cm">
  <g fill="none" stroke-width="30">
    <rect width="400" height="200" stroke="lightgray"/>
    <rect width="400" height="200" stroke="darkgreen" transform="rotate(-30)"/>
    <g transform="translate(700 100) rotate(-30)">
      <rect width="400" height="200" stroke="blue"/>
    </g>
  </g>
</svg>

Output

Transform example

Style Properties

The following style properties are supported on SVG elements:

  • baseline-shift
  • clip-path
  • clip-rule
  • dominant-baseline
  • font-family
  • font-size
  • font-style
  • font-weight
  • fill
  • fill-opacity
  • fill-rule
  • marker-start
  • marker-mid
  • marker-end
  • stop-color
  • stop-opacity
  • stroke
  • stroke-dasharray
  • stroke-dashoffset
  • stroke-linecap
  • stroke-linejoin
  • stroke-miterlimit
  • stroke-opacity
  • stroke-width
  • text-anchor

Style properties can be applied using SVG presentation attributes:

<rect fill="yellow" stroke="blue" stroke-width="20"
        width="200" height="100"/>

Or by using CSS properties inside the style attribute or element:

<rect style="fill:yellow; stroke:blue; stroke-width:20"
        width="200" height="100"/>
Copyright © 2002 – 2019 YesLogic Pty. Ltd.
  • About Us
  • Privacy Policy
  • Contact Us