Glossary#
Colors#
Colors are specified as arrays with the appropriate number of components for the ColorSpace. Each number is a floating point between 0
and 1
for the component value.
Therefore colors are represented as an array of up to 4 component values.
For example:
In the
DeviceCMYK
color space a color would be[Cyan,Magenta,Yellow,Black]
. A full magenta color would therefore be[0,1,0,0]
.In the
DeviceRGB
color space a color would be[Red,Green,Blue]
. A full green color would therefore be[0,1,0]
.In the
DeviceGray
color space a color would be[Black]
. A full black color would therefore be[0]
.
Color
Type#
The convenience type is defined as follows:
type Color = [number] | [number, number, number] | [number, number, number, number]
Alpha#
Alpha values are floats between 0
and 1
, whereby 0
denotes full transparency & 1
denotes full opacity.
Matrices#
Matrices are simply 6-element arrays representing a 3-by-3 transformation matrix as:
/ a b 0 \
| c d 0 |
\ e f 1 /
This matrix is represented in JavaScript as [a,b,c,d,e,f]
.
Matrix
Type#
The convenience type is defined as follows:
type Matrix = [number, number, number, number, number, number]
Matrix
#
Properties
identity
The identity matrix, short hand for
[1,0,0,1,0,0]
.EXAMPLE
var m = mupdfjs.Matrix.identity;
Methods
- scale(sx: number, sy: number)#
Returns a scaling matrix, short hand for
[sx,0,0,sy,0,0]
.- Parameters:
sx –
number
. X scale as a floating point number.sy –
number
. Y scale as a floating point number.
- Returns:
[a,b,c,d,e,f]
.
EXAMPLE
var m = mupdfjs.Matrix.scale(2,2);
- translate(tx: number, ty: number)#
Return a translation matrix, short hand for
[1,0,0,1,tx,ty]
.- Parameters:
tx –
number
. X translation as a floating point number.ty –
number
. Y translation as a floating point number.
- Returns:
[a,b,c,d,e,f]
.
EXAMPLE
var m = mupdfjs.Matrix.translate(2,2);
- rotate(theta: number)#
Return a rotation matrix, short hand for
[cos(theta),sin(theta),-sin(theta),cos(theta),0,0]
.- Parameters:
theta –
number
. Rotation value.- Returns:
[a,b,c,d,e,f]
.
EXAMPLE
var m = mupdfjs.Matrix.rotate(90);
- concat(a: [a, b, c, d, e, f], b: [a, b, c, d, e, f])#
Concatenate matrices
a
andb
. Bear in mind that matrix multiplication is not commutative.- Parameters:
a –
[a,b,c,d,e,f]
. Matrix “a”.b –
[a,b,c,d,e,f]
. Matrix “b”.
- Returns:
[a,b,c,d,e,f]
.
EXAMPLE
var m = mupdfjs.Matrix.concat([1,1,1,1,1,1], [2,2,2,2,2,2]);
- invert(matrix: [a, b, c, d, e, f])#
Inverts the supplied matrix and returns the result.
- Parameters:
matrix –
[a,b,c,d,e,f]
. Matrix array.- Returns:
[a,b,c,d,e,f]
.
EXAMPLE
var m = mupdfjs.Matrix.invert([1,0.5,1,1,1,1]);
Rectangles#
Rectangles are 4-element arrays, specifying the minimum and maximum corners (typically upper left and lower right, in a coordinate space with the origin at the top left with descending y): [ulx,uly,lrx,lry]
. Rectangles are always X- and Y-axis aligned.
If the minimum x coordinate is bigger than the maximum x coordinate, MuPDF treats the rectangle as infinite in size.
Rect
Type#
The convenience type is defined as follows:
type Rect = [number, number, number, number]
Rect
#
Methods
- isEmpty(rect: [x1, y1, x2, y2])#
Returns a boolean indicating if the rectangle is empty or not.
- Parameters:
rect –
[x1,y1,x2,y2]
. Rectangle array.- Returns:
boolean
.
EXAMPLE
var isEmpty = mupdfjs.Rect.isEmpty([0,0,0,0]); // true var isEmpty = mupdfjs.Rect.isEmpty([0,0,100,100]); // false
- isValid(rect: [x1, y1, x2, y2])#
Returns a boolean indicating if the rectangle is valid or not. Rectangles are considered “invalid” if
lrx
<ulx
and/or iflry
<uly
.- Parameters:
rect –
[x1,y1,x2,y2]
. Rectangle array.- Returns:
boolean
.
EXAMPLE
var isValid = mupdfjs.Rect.isValid([0,0,100,100]); // true var isValid = mupdfjs.Rect.isValid([0,0,-100,100]); // false
- isInfinite(rect: [x1, y1, x2, y2])#
Returns a boolean indicating if the rectangle is infinite or not.
- Parameters:
rect –
[x1,y1,x2,y2]
. Rectangle array.- Returns:
boolean
.
EXAMPLE
var isInfinite = mupdfjs.Rect.isInfinite([0x80000000,0x80000000,0x7fffff80,0x7fffff80]); //true var isInfinite = mupdfjs.Rect.isInfinite([0,0,100,100]); // false
- transform(rect: [x1, y1, x2, y2], matrix: [a, b, c, d, e, f])#
Returns a rectangle generated by transforming the supplied
rect
by thematrix
.- Parameters:
rect –
[x1,y1,x2,y2
.Rectangle
array.matrix –
[a,b,c,d,e,f]
.Matrix
array.
- Returns:
[x1,y1,x2,y2]
.
EXAMPLE
var m = mupdfjs.Rect.transform([0,0,100,100], [1,0.5,1,1,1,1]);
Points#
Points objects are two-dimensonial numeric arrays in the format: [x, y]
.
Point
Type#
The convenience type is defined as follows:
type Point = [number, number]
Quads#
QuadPoint or Quad objects are arrays of 8 elements, where each pair are the X/Y coordinates of a corner of the quad, i.e.: [ulx, uly, urx, ury, llx, lly, lrx, lry]
.
Quad
Type#
The convenience type is defined as follows:
type Quad = [number, number, number, number, number, number, number, number]
Page Boxes#
Page boxes are rectangles that define different areas of a PDF page, such as the content area, the trim area, and the bleed area.
PageBox
Type#
The convenience type is defined as follows:
type PageBox = "MediaBox" | "CropBox" | "BleedBox" | "TrimBox" | "ArtBox"
Note
Explanation of box types:
MediaBox for complete pages including items that will be physically trimmed from the final product like crop marks, registration marks, etc.
CropBox defines the region that a PDF is expected to display or print.
BleedBox determines the region to which the page contents expect to be clipped.
TrimBox defines the intended dimensions of the finished page.
ArtBox can be used to denote areas where it is considered “safe” to place graphical elements.
Annotations#
Annotation Types#
PDFAnnotationType
Name |
Supported (can be created) |
Notes |
---|---|---|
Text |
Yes |
This is a “Note” style annotation |
Link |
Yes |
Please use |
FreeText |
Yes |
|
Square |
Yes |
|
Circle |
Yes |
|
Line |
Yes |
|
Polygon |
Yes |
|
PolyLine |
Yes |
|
Highlight |
Yes |
|
Underline |
Yes |
|
Squiggly |
Yes |
|
StrikeOut |
Yes |
|
Redact |
Yes |
|
Stamp |
Yes |
|
Caret |
Yes |
|
Ink |
Yes |
|
Popup |
No |
|
FileAttachment |
Yes |
|
Sound |
No |
|
Movie |
No |
|
RichMedia |
No |
|
Widget |
No |
|
Screen |
No |
|
PrinterMark |
No |
|
TrapNet |
No |
|
Watermark |
No |
|
3D |
No |
|
Projection |
No |
The following list defines the creatable annotations as a sub-set from PDFAnnotationType
.
CreatableAnnotationType
Name |
---|
Text |
FreeText |
Square |
Circle |
Line |
Polygon |
PolyLine |
Highlight |
Underline |
Squiggly |
StrikeOut |
Redact |
Stamp |
Caret |
Ink |
FileAttachment |
Widgets Types#
Widgets are a special type of interactive annotation used for form filling in PDF.
Name |
---|
button |
checkbox |
combobox |
listbox |
radiobutton |
signature |
text |
Line Ending Styles#
The following table lists line ending styles for use with PDFAnnotation.
PDFAnnotationLineEndingStyle
Line ending names |
---|
“None” |
“Square” |
“Circle” |
“Diamond” |
“OpenArrow” |
“ClosedArrow” |
“Butt” |
“ROpenArrow” |
“RClosedArrow” |
“Slash” |
Icon Names#
The following table lists icon names for use with PDFAnnotation.
Icon type |
Icon name |
---|---|
File attachment |
“Graph” |
“PaperClip” |
|
“PushPin” |
|
“Tag” |
|
Sound |
“Mic” |
“Speaker” |
|
Stamp |
“Approved” |
“AsIs” |
|
“Confidential” |
|
“Departmental” |
|
“Draft” |
|
“Experimental” |
|
“Expired” |
|
“Final” |
|
“ForComment” |
|
“ForPublicRelease” |
|
“NotApproved” |
|
“NotForPublicRelease” |
|
“Sold” |
|
“TopSecret” |
|
Text |
“Comment” |
“Help” |
|
“Insert” |
|
“Key” |
|
“NewParagraph” |
|
“Note” |
|
“Paragraph” |
Border Style#
Annotation border styles are one of:
“Solid” |
“Dashed” |
Border Effect#
Annotation border effects are one of:
“None” |
“Cloudy” |
Object Protocols#
The following objects are standard JavaScript objects with assumed properties (i.e. they follow their outlined protocol). They are used throughout the API to support object types for various methods.
Link Destination Object#
A link destination points to a location within a document and how a document viewer should show that destination.
It consists of a dictionary with keys for:
chapter
The chapter within the document.
page
The page within the document.
type
Either “Fit”, “FitB”, “FitH”, “FitBH”, “FitV”, “FitBV”, “FitR” or “XYZ”, controlling which of the keys below exist.
x
The left coordinate, valid for “FitV”, “FitBV”, “FitR” and “XYZ”.
y
The top coordinate, valid for “FitH”, “FitBH”, “FitR” and “XYZ”.
width
The width of the zoomed in region, valid for “XYZ”.
height
The height of the zoomed in region, valid for “XYZ”.
zoom
The zoom factor, valid for “XYZ”.
File Specification Object#
This object is used to represent a file.
In order to retrieve information from this object see methods described within Embedded files in PDFs.
Filespec Params Object#
This Object
contains metadata about a filespec, it has properties for:
filename
The name of the embedded file.
mimetype
The MIME type of the embedded file, or
undefined
if none exists.size
The size in bytes of the embedded file contents.
creationDate
The creation date of the embedded file.
modificationDate
The modification date of the embedded file.
PDF Journal Object#
This Object
contains a numbered array of operations and a reference into this list indicating the current position.
position
The current position in the journal.
steps
An array containing the name of each step in the journal.
Stroking State Object#
The stroking state is a dictionary with keys for:
startCap
,dashCap
,endCap
“Butt”, “Round”, “Square”, or “Triangle”.
lineCap
Set
startCap
,dashCap
, andendCap
all at once.lineJoin
“Miter”, “Round”, “Bevel”, or “MiterXPS”.
lineWidth
Thickness of the line.
miterLimit
Maximum ratio of the miter length to line width, before beveling the join instead.
dashPhase
Starting offset for dash pattern.
dashes
Array of on/off dash lengths.
EXAMPLE
{dashes:[5,10], lineWidth:3, lineCap:'Round'}
Default Appearance Text Object#
font
String representing the font.
size
Number representing the size of the font.
color
Array representing the color value.
Page Labels#
Page labels are used to label your pages - giving them a name, usually this is the page number, however there may be prefixes or other kinds of labels (e.g. roman numerals) that you may want to use.
There is a common interface object in MuPDF.js which is used to define a page label rule as follows:
interface PageLabelRule {
startpage: number;
prefix?: string;
style?: string;
firstpagenum?: number;
}
Outline Items#
Outline items are returned from the loadOutline()
method and represent a table of contents entry.
interface OutlineItem {
title: string | undefined,
uri: string | undefined,
open: boolean,
down?: OutlineItem[],
page?: number,
}
Blend Modes#
BlendMode
is defined as a string as one of:
Normal |
Multiply |
Screen |
Overlay |
Darken |
Lighten |
ColorDodge |
ColorBurn |
HardLight |
SoftLight |
Difference |
Exclusion |
Hue |
Saturation |
Color |
Luminosity |