Contents Menu Expand Light mode Dark mode Auto light/dark mode
MuPDF.NET documentation
Light Logo Dark Logo
MuPDF.NET documentation

Welcome

  • Getting Started
  • The Basics

API REFERENCE

  • Classes
    • Annot
    • Archive
    • Barcode
    • ColorSpace
    • DisplayList
    • Document
    • DocumentWriter
    • Font
    • IdentityMatrix
    • ImageFilter
    • ImageFilterPipeline
    • IRect
    • Link
    • Matrix
    • Outline
    • Page
    • Pixmap
    • Point
    • Quad
    • Rect
    • Shape
    • Story
    • TextPage
    • TextWriter
    • Widget
    • Xml
  • Utils
  • Constants and Enumerations
  • Migrating from ByteScout SDK
Back to top
Find #mupdf_net on Discord
Try our forum! MuPDF Forum link logo

Link#

Represents a pointer to somewhere (this document, other documents, the internet). Links exist per document page, and they are forward-chained to each other, starting from an initial link which is accessible by the MuPDFPage.FirstLink property.

There is a parent-child relationship between a link and its page. If the page object becomes unusable (closed document, any document structure change, etc.), then so does every of its existing link objects – an exception is raised saying that the object is “orphaned”, whenever a link property or method is accessed.

Method / Attribute

Short Description

Link.SetBorder()

Modify border properties

Link.SetColors()

Modify color properties

Link.SetFlags()

Modify link flags

Link.Border

Border characteristics

Link.Color

Border stroke and interior color

Link.Dest

Points to destination details

Link.IsExternal

Checks if the link is an external destination

Link.Flags

Link annotation flags

Link.Next

Points to next link

Link.Rect

Clickable area in untransformed coordinates

Link.Uri

Link destination

Link.Xref

xref number of the entry

Class API

class Link#
SetBorder(Border border: null, float width: 0, string style: null, int[] dashes: null)#

PDF only: Change border width and dashing properties.

Parameters:
  • border (Border) – a dictionary as returned by the Border property, with keys “width” (float), “style” (string) and “dashes” (int[]). Omitted keys will leave the resp. property unchanged. To e.g. remove dashing use: “dashes”: []. If dashes is not an empty sequence, “style” will automatically be set to “D” (dashed).

  • width (float) – see above.

  • style (string) – see above.

  • dashes (int[]) – see above.

SetColors(Color colors: null, float[] stroke: null, float[] fill: null)#

PDF only: Changes the “stroke” color.

Note

In PDF, links are a subtype of annotations technically and do not support fill colors. However, to keep a consistent API, we do allow specifying a fill= parameter like with all annotations, which will be ignored with a warning.

Parameters:
  • colors (Color) – a dictionary containing color specifications. For accepted dictionary keys and values see below. The most practical way should be to first make a copy of the colors property and then modify this dictionary as required.

  • stroke (float[]) – see above.

  • fill (float[]) – see above.

SetFlags(int flags)#

Set the PDF /F property of the link annotation. See Annot.SetFlags() for details. If not a PDF, this method is a no-op.

Flags#

Return the link annotation flags, an integer (see Annot.Flags for details). Zero if not a PDF.

Color#

Meaningful for PDF only: A dictionary of two tuples of floats in range 0 <= float <= 1 specifying the stroke and the interior (fill) colors. If not a PDF, null is returned. As mentioned above, the fill color is always null for links. The stroke color is used for the border of the link rectangle. The length of the tuple implicitly determines the colorspace: 1 = GRAY, 3 = RGB, 4 = CMYK. So (1.0, 0.0, 0.0) stands for RGB color red. The value of each float f is mapped to the integer value i in range 0 to 255 via the computation f = i / 255.

Return type:

dict

Border#

Meaningful for PDF only: A dictionary containing border characteristics. It will be null for non-PDFs and an empty dictionary if no border information exists. The following keys can occur:

  • width – a float indicating the border thickness in points. The value is -1.0 if no width is specified.

  • dashes – a sequence of integers specifying a line dash pattern. [] means no dashes, [n] means equal on-off lengths of n points, longer lists will be interpreted as specifying alternating on-off length values. See the Adobe PDF References page 126 for more detail.

  • style – 1-byte border style: S (Solid) = solid rectangle surrounding the annotation, D (Dashed) = dashed rectangle surrounding the link, the dash pattern is specified by the dashes entry, B (Beveled) = a simulated embossed rectangle that appears to be raised above the surface of the page, I (Inset) = a simulated engraved rectangle that appears to be recessed below the surface of the page, U (Underline) = a single line along the bottom of the annotation rectangle.

Return type:

dict

Rect#

The area that can be clicked in untransformed coordinates.

Type:

Rect

IsExternal#

A bool specifying whether the link target is outside of the current document.

Type:

bool

Uri#

A string specifying the link target. The meaning of this property should be evaluated in conjunction with property IsExternal:

  • IsExternal is true: uri points to some target outside the current PDF, which may be an internet resource (uri starts with http:// or similar), another file (uri starts with “file:” or file://) or some other service like an e-mail address (uri starts with mailto:).

  • IsExternal is false: uri will be null or point to an internal location. In case of PDF documents, this should either be #nnnn to indicate a 1-based (!) page number nnnn, or a named location. The format varies for other document types, for example “../FixedDoc.fdoc#PG_2_LNK_1” for page number 2 (1-based) in an XPS document.

Type:

string

Xref#

An integer specifying the PDF Xref. Zero if not a PDF.

Type:

int

Next#

The next link or null.

Type:

Link

Dest#

The link destination details object.

Type:

LinkDest


Next
Matrix
Previous
IRect
Copyright © 2023-2026, Artifex
Made with Furo
Last updated on 01. May 2026
On this page
  • Link
    • Link
      • Link.SetBorder()
      • Link.SetColors()
      • Link.SetFlags()
      • Link.Flags
      • Link.Color
      • Link.Border
      • Link.Rect
      • Link.IsExternal
      • Link.Uri
      • Link.Xref
      • Link.Next
      • Link.Dest