Table of Contents

Class Page

Namespace
PDFjet.NET
Assembly
PDFjet.dll

Used to create PDF page objects.

Please note:

The coordinate (0.0f, 0.0f) is the top left corner of the page.
The size of the pages are represented in points.
1 point is 1/72 inches.
public class Page
Inheritance
Page
Inherited Members

Constructors

Page(PDF, PDFobj)

Creates a page from a page object read from an existing PDF.

public Page(PDF pdf, PDFobj pageObj)

Parameters

pdf PDF
pageObj PDFobj

Page(PDF, PageSize)

Creates page object and add it to the PDF document.

Please note:

The coordinate (0.0, 0.0) is the top left corner of the page.
The size of the pages are represented in points.
1 point is 1/72 inches.
public Page(PDF pdf, PageSize pageSize)

Parameters

pdf PDF

the pdf object.

pageSize PageSize

the page size of this page.

Page(PDF, PageSize, bool)

Creates page object and add it to the PDF document.

Please note:

The coordinate (0.0, 0.0) is the top left corner of the page.
The size of the pages are represented in points.
1 point is 1/72 inches.
public Page(PDF pdf, PageSize pageSize, bool addPageToPDF)

Parameters

pdf PDF

the pdf object.

pageSize PageSize

the page size of this page.

addPageToPDF bool

bool flag.

Fields

DETACHED

Pass to the Page constructor to create a page that is not added to the PDF right away.

public const bool DETACHED = false

Field Value

bool

MSCALE_X

Index of the horizontal scale in an Android Matrix value array.

public const int MSCALE_X = 0

Field Value

int

MSCALE_Y

Index of the vertical scale in an Android Matrix value array.

public const int MSCALE_Y = 4

Field Value

int

MSKEW_X

Index of the horizontal skew in an Android Matrix value array.

public const int MSKEW_X = 1

Field Value

int

MSKEW_Y

Index of the vertical skew in an Android Matrix value array.

public const int MSKEW_Y = 3

Field Value

int

MTRANS_X

Index of the horizontal translation in an Android Matrix value array.

public const int MTRANS_X = 2

Field Value

int

MTRANS_Y

Index of the vertical translation in an Android Matrix value array.

public const int MTRANS_Y = 5

Field Value

int

Methods

AddArcToPath(float, float, float, float, float, float)

Adds an elliptical arc to the current path.

public float[] AddArcToPath(float x, float y, float rx, float ry, float startAngle, float sweepDegrees)

Parameters

x float

the x coordinate of the center.

y float

the y coordinate of the center.

rx float

the horizontal radius.

ry float

the vertical radius.

startAngle float

the start angle in degrees.

sweepDegrees float

the sweep angle in degrees.

Returns

float[]

the control points and the end point of the last curve segment.

AddArtifactBMC()

Begins an artifact marked content sequence.

public void AddArtifactBMC()

AddBDC(StructElem, string, string)

Begins a marked content sequence with the structure, actual text and alternate description.

public void AddBDC(StructElem structure, string actualText, string altDescription)

Parameters

structure StructElem
actualText string
altDescription string

AddBDC(StructElem, string, string, string)

Begins a marked content sequence with the structure, language, actual text and alternate description.

public void AddBDC(StructElem structure, string language, string actualText, string altDescription)

Parameters

structure StructElem
language string
actualText string
altDescription string

AddCircularArcToPath(float, float, float, float, float)

Adds a circular arc to the current path.

public float[] AddCircularArcToPath(float x, float y, float r, float startAngle, float sweepDegrees)

Parameters

x float

the x coordinate of the center.

y float

the y coordinate of the center.

r float

the radius.

startAngle float

the start angle in degrees.

sweepDegrees float

the sweep angle in degrees.

Returns

float[]

the control points and the end point of the last curve segment.

AddDestination(string, float)

Adds destination to this page.

public Destination AddDestination(string name, float yPosition)

Parameters

name string

The destination name.

yPosition float

The vertical position of the destination on this page.

Returns

Destination

the destination.

AddDestination(string, float, float)

Adds destination to this page.

public Destination AddDestination(string name, float xPosition, float yPosition)

Parameters

name string

The destination name.

xPosition float

The horizontal position of the destination on this page.

yPosition float

The vertical position of the destination on this page.

Returns

Destination

the destination.

AddEMC()

Ends the current marked content sequence.

public void AddEMC()

AddFooter(TextLine)

Draws the text line centered at the bottom of the page.

public float[] AddFooter(TextLine textLine)

Parameters

textLine TextLine

Returns

float[]

AddFooter(TextLine, float)

Draws the text line centered at the bottom of the page, with its baseline at the specified offset from the bottom.

public float[] AddFooter(TextLine textLine, float offset)

Parameters

textLine TextLine
offset float

Returns

float[]

AddHeader(TextLine)

Draws the text line centered at the top of the page.

public float[] AddHeader(TextLine textLine)

Parameters

textLine TextLine

Returns

float[]

AddHeader(TextLine, float)

Draws the text line centered at the top of the page, with its baseline at the specified offset.

public float[] AddHeader(TextLine textLine, float offset)

Parameters

textLine TextLine
offset float

Returns

float[]

AddResource(Font, List<PDFobj>)

Adds a font to the resources of this page.

public void AddResource(Font font, List<PDFobj> objects)

Parameters

font Font
objects List<PDFobj>

AddResource(Image, List<PDFobj>)

Adds an image to the resources of this page.

public void AddResource(Image image, List<PDFobj> objects)

Parameters

image Image
objects List<PDFobj>

AddResource(int, List<PDFobj>)

Adds a core font to the resources of this page and returns the font.

public Font AddResource(int coreFont, List<PDFobj> objects)

Parameters

coreFont int
objects List<PDFobj>

Returns

Font

AddWatermark(Font, string)

Draws the text as a watermark diagonally across the page.

public void AddWatermark(Font font, string text)

Parameters

font Font
text string

BeginStructElement(StructElem)

Begins a structure element of a tagged document, PDF/UA or a PDF/A of level A, that what is drawn until EndStructElement becomes the kids of, like the L of a list whose items are drawn one at a time. The calls nest, and every one needs its EndStructElement. In a document that is not tagged both do nothing.

public void BeginStructElement(StructElem structure)

Parameters

structure StructElem

BezierCurveTo(Point, Point, Point)

Draws a bezier curve starting from the current point. Please note: You must call the StrokePath, ClosePath or FillPath methods after the last BezierCurveTo call.

Author: Pieter Libin, pieter@emweb.be

public void BezierCurveTo(Point p1, Point p2, Point p3)

Parameters

p1 Point

this first control point.

p2 Point

this second control point.

p3 Point

this end point.

ClipPath()

Clips the path.

public void ClipPath()

ClipRect(float, float, float, float)

Sets the clipping path to the specified rectangle.

public void ClipRect(float x, float y, float w, float h)

Parameters

x float
y float
w float
h float

ClosePath()

Closes the current path and then strokes it using the active pen color.

public void ClosePath()

Complete(List<PDFobj>)

Finishes a page read from an existing PDF by adding its new content to the objects.

public void Complete(List<PDFobj> objects)

Parameters

objects List<PDFobj>

CurveTo(float, float, float, float, float, float)

Draws a cubic bezier curve starting from the current point to the end point p3

public void CurveTo(float x1, float y1, float x2, float y2, float x3, float y3)

Parameters

x1 float

first control point x

y1 float

first control point y

x2 float

second control point x

y2 float

second control point y

x3 float

end point x

y3 float

end point y

DrawCircle(float, float, float)

Draws a circle on the page. The outline of the circle is drawn using the current pen color.

public void DrawCircle(float x, float y, float r)

Parameters

x float

the x coordinate of the center of the circle to be drawn.

y float

the y coordinate of the center of the circle to be drawn.

r float

the radius of the circle to be drawn.

DrawContents(byte[], float, float, float, float, float)

Draws the content stream scaled and placed at the specified location.

public void DrawContents(byte[] content, float h, float x, float y, float xScale, float yScale)

Parameters

content byte[]
h float
x float
y float
xScale float
yScale float

DrawEllipse(float, float, float, float)

Draws an ellipse on the page using the current pen color.

public void DrawEllipse(float x, float y, float r1, float r2)

Parameters

x float

the x coordinate of the center of the ellipse to be drawn.

y float

the y coordinate of the center of the ellipse to be drawn.

r1 float

the horizontal radius of the ellipse to be drawn.

r2 float

the vertical radius of the ellipse to be drawn.

DrawLine(float, float, float, float)

Draws a line on the page, using the current color, between the points (x1, y1) and (x2, y2).

public void DrawLine(float x1, float y1, float x2, float y2)

Parameters

x1 float

the first point's x coordinate.

y1 float

the first point's y coordinate.

x2 float

the second point's x coordinate.

y2 float

the second point's y coordinate.

DrawPath(List<Point>, PathOperator)

Draws a path consisting of multiple points using the specified path operator. Supports both straight line segments and Bézier curve segments with control points.

public void DrawPath(List<Point> path, PathOperator pathOperator)

Parameters

path List<Point>

The list of points defining the path. The first point sets the starting position, subsequent points define line segments or curve control points. Fewer than two points paint nothing.

pathOperator PathOperator

The path painting operator to apply, for example PathOperator.STROKE or PathOperator.FILL.

Examples

// Drawing a rectangle with straight lines
List<Point> rect = new List<Point> {
    new Point(100, 100),
    new Point(200, 100),
    new Point(200, 200),
    new Point(100, 200)
};
DrawPath(rect, PathOperator.STROKE);
// Drawing a cubic Bézier curve
List<Point> curve = new List<Point> {
    new Point(100, 100),           // Start point
    new Point(150, 50, Point.CONTROL_POINT_C),    // First control point
    new Point(250, 150, Point.CONTROL_POINT_C),   // Second control point
    new Point(300, 100)            // End point
};
DrawPath(curve, PathOperator.STROKE);

Remarks

The method processes points as follows:

  • Starts with MoveTo() to position at the first point
  • For each subsequent point:
    • If the point has a controlPoint set: stores it for curve definition
    • If the point has no controlPoint:
      • If previous point had controlPoint: completes curve definition
      • Otherwise: creates straight line segment using LineTo()
  • Applies the specified path operator at the end

This method supports both simple polygonal paths and complex paths with Bézier curves. Control points should have their controlPoint property set to indicate curve type (e.g., 'C' for cubic Bézier, 'Q' for quadratic Bézier). A path that ends on a control point, whose curve has no end, is refused and nothing of it is drawn.

See Also

DrawPoint(Point)

Draws a point on the page using the current pen color.

public void DrawPoint(Point p)

Parameters

p Point

the point.

DrawRect(float, float, float, float)

Draws the outline of a rectangle using the current pen color.

public void DrawRect(float x, float y, float w, float h)

Parameters

x float

X‑coordinate of the top left corner.

y float

Y‑coordinate of the top left corner.

w float

Rectangle width.

h float

Rectangle height.

DrawRoundedRect(float, float, float, float, float, float)

Draws the outline of a rectangle with rounded corners using the current pen color.

public void DrawRoundedRect(float x, float y, float w, float h, float r1, float r2)

Parameters

x float

the x coordinate of the top left corner.

y float

the y coordinate of the top left corner.

w float

the width.

h float

the height.

r1 float

the horizontal radius of the corners.

r2 float

the vertical radius of the corners.

DrawString(Font, Font, float, string, float, float)

Draws the string in black. The fallback font is used for characters the main font does not have.

public void DrawString(Font font, Font fallbackFont, float fontSize, string str, float x, float y)

Parameters

font Font
fallbackFont Font
fontSize float
str string
x float
y float

DrawString(Font, float, string, float, float)

Draws the string in black with its baseline at the specified location.

public void DrawString(Font font, float fontSize, string str, float x, float y)

Parameters

font Font
fontSize float
str string
x float
y float

DrawString(Font, float, string, float, float, float)

Draws each character of str at successive X positions, advancing by dx after every glyph.

public void DrawString(Font font, float fontSize, string str, float x, float y, float dx)

Parameters

font Font

Font used for rendering.

fontSize float

Size of the font.

str string

Text to draw.

x float

Starting X coordinate.

y float

Baseline Y coordinate.

dx float

Horizontal offset applied after each character.

EndStructElement()

Ends the structure element that BeginStructElement began.

public void EndStructElement()

FillCircle(float, float, float)

Fills a circle on the page using the current brush color.

public void FillCircle(float x, float y, float r)

Parameters

x float

the x coordinate of the center of the circle to be filled.

y float

the y coordinate of the center of the circle to be filled.

r float

the radius of the circle to be filled.

FillEllipse(float, float, float, float)

Fills an ellipse on the page using the current brush color.

public void FillEllipse(float x, float y, float r1, float r2)

Parameters

x float

the x coordinate of the center of the ellipse to be drawn.

y float

the y coordinate of the center of the ellipse to be drawn.

r1 float

the horizontal radius of the ellipse to be drawn.

r2 float

the vertical radius of the ellipse to be drawn.

FillPath()

Closes the current path and fills it using the active brush color.

public void FillPath()

FillRect(float, float, float, float)

Fills a rectangle using the current brush color.

public void FillRect(float x, float y, float w, float h)

Parameters

x float

X‑coordinate of the top left corner.

y float

Y‑coordinate of the top left corner.

w float

Rectangle width.

h float

Rectangle height.

FillRoundedRect(float, float, float, float, float, float)

Fills a rectangle with rounded corners using the current brush color.

public void FillRoundedRect(float x, float y, float w, float h, float r1, float r2)

Parameters

x float

the x coordinate of the top left corner.

y float

the y coordinate of the top left corner.

w float

the width.

h float

the height.

r1 float

the horizontal radius of the corners.

r2 float

the vertical radius of the corners.

GetBrushColor()

Returns a copy of the current brush color as an RGB float array.

public float[] GetBrushColor()

Returns

float[]

A float[] containing the red, green, and blue components (0.0f to 1.0f) of the brush color.

GetContent()

Returns the content stream of this page.

public byte[] GetContent()

Returns

byte[]

GetHeight()

Returns the height of this page.

public float GetHeight()

Returns

float

the height of the page.

GetPenColor()

Gets a copy of the current pen color as an RGB float array.

public float[] GetPenColor()

Returns

float[]

A float[] with three elements: red, green, and blue components (0.0f to 1.0f).

GetPenWidth()

Returns the current pen width.

public float GetPenWidth()

Returns

float

GetWidth()

Returns the width of this page.

public float GetWidth()

Returns

float

the width of the page.

InvertYAxis()

Flips the y axis, so the origin is the top left corner of the page and y grows downward.

public void InvertYAxis()

LineTo(float, float)

Draws a line from the current pen position to the point with coordinates (x, y),

public void LineTo(float x, float y)

Parameters

x float

The horizontal offset for the line endpoint.

y float

The vertical offset for the line endpoint (before Y‑axis inversion).

MoveTo(float, float)

Moves the pen to the absolute point (x, y) on the page.

public void MoveTo(float x, float y)

Parameters

x float

Horizontal coordinate of the new position.

y float

Vertical coordinate (before Y‑axis flip).

Remarks

Converts Y to height - y because the renderer uses a top‑left origin. Appends a move‑to command in the form “x y m\n”.

RestoreGraphicsState()

Restores the graphics state. Please see Example_30.

public void RestoreGraphicsState()

SaveGraphicsState()

Saves the graphics state. Please see Example_30.

public void SaveGraphicsState()

SetArtBox(float, float, float, float)

Sets the page ArtBox. See page 77 of the PDF32000_2008.pdf specification.

public Page SetArtBox(float upperLeftX, float upperLeftY, float lowerRightX, float lowerRightY)

Parameters

upperLeftX float

the top left X coordinate of the ArtBox.

upperLeftY float

the top left Y coordinate of the ArtBox.

lowerRightX float

the bottom right X coordinate of the ArtBox.

lowerRightY float

the bottom right Y coordinate of the ArtBox.

Returns

Page

this Page object.

SetBleedBox(float, float, float, float)

Sets the page BleedBox. See page 77 of the PDF32000_2008.pdf specification.

public Page SetBleedBox(float upperLeftX, float upperLeftY, float lowerRightX, float lowerRightY)

Parameters

upperLeftX float

the top left X coordinate of the BleedBox.

upperLeftY float

the top left Y coordinate of the BleedBox.

lowerRightX float

the bottom right X coordinate of the BleedBox.

lowerRightY float

the bottom right Y coordinate of the BleedBox.

Returns

Page

this Page object.

SetBrushColor(int)

Sets the brush color. Color.transparent leaves it unchanged.

public Page SetBrushColor(int color)

Parameters

color int

the color. See the Color class for predefined values or define your own using 0x00RRGGBB packed integers.

Returns

Page

this Page object.

SetBrushColor(float[])

Sets the color for brush operations.

public Page SetBrushColor(float[] rgbColor)

Parameters

rgbColor float[]

the color.

Returns

Page

this Page object.

SetBrushColorCMYK(float, float, float, float)

Sets the color for brush operations using CMYK. This is the color used when drawing regular text and filling shapes.

public Page SetBrushColorCMYK(float c, float m, float y, float k)

Parameters

c float

the cyan component is float value from 0.0f to 1.0f.

m float

the magenta component is float value from 0.0f to 1.0f.

y float

the yellow component is float value from 0.0f to 1.0f.

k float

the black component is float value from 0.0f to 1.0f.

Returns

Page

this Page object.

SetCropBox(float, float, float, float)

Sets the page CropBox. See page 77 of the PDF32000_2008.pdf specification.

public Page SetCropBox(float upperLeftX, float upperLeftY, float lowerRightX, float lowerRightY)

Parameters

upperLeftX float

the top left X coordinate of the CropBox.

upperLeftY float

the top left Y coordinate of the CropBox.

lowerRightX float

the bottom right X coordinate of the CropBox.

lowerRightY float

the bottom right Y coordinate of the CropBox.

Returns

Page

this Page object.

SetDefaultPenWidth()

Sets the line width to the default. The default is the finest line width.

public Page SetDefaultPenWidth()

Returns

Page

this Page object.

SetDefaultStrokeDashPattern()

Sets the default stroke pattern to be solid line or curve.

public Page SetDefaultStrokeDashPattern()

Returns

Page

this Page object.

SetFigureBoundingBox(float, float, float, float)

Sets the bounding box of the figure that AddBDC began last: the box it is drawn in, x and y its top left corner, w wide and h tall. PDF/UA asks for the bounding box of every figure, which a screen reader or a program that reflows the page uses to find it. The figures of the library, images, SVG images, charts, barcodes and QR codes, set it themselves; a figure drawn with AddBDC and AddEMC around other drawing needs it set before AddEMC. It does nothing in a document that is not tagged.

public void SetFigureBoundingBox(float x, float y, float w, float h)

Parameters

x float
y float
w float
h float

SetGraphicsState(GraphicsState)

Sets the graphics state. Please see Example_30.

public Page SetGraphicsState(GraphicsState gs)

Parameters

gs GraphicsState

the graphics state to use.

Returns

Page

this Page object.

SetLineCapStyle(CapStyle)

Sets the current line cap style.

public Page SetLineCapStyle(CapStyle style)

Parameters

style CapStyle

the cap style of the current line. Supported values: CapStyle.BUTT, CapStyle.ROUND and CapStyle.PROJECTING_SQUARE

Returns

Page

this Page object.

SetLineJoinStyle(JoinStyle)

Sets the line join style.

public Page SetLineJoinStyle(JoinStyle style)

Parameters

style JoinStyle

the line join style code. Supported values: JoinStyle.MITER, JoinStyle.ROUND and JoinStyle.BEVEL

Returns

Page

this Page object.

SetPenColor(int)

Sets the pen color using a packed 0x00RRGGBB integer value. Color.transparent leaves it unchanged.

public Page SetPenColor(int color)

Parameters

color int

The color value, where each component (red, green, blue) is packed into a 24-bit integer. You can use predefined colors from the Color class or define your own.

Returns

Page

SetPenColor(float[])

Sets the pen color using an RGB color array.

public Page SetPenColor(float[] rgbColor)

Parameters

rgbColor float[]

An array of three float values for red, green, and blue components (0.0f to 1.0f).

Returns

Page

Remarks

Logs a warning and does not set the color if the values are out of range or the array is null.

SetPenColorCMYK(float, float, float, float)

Sets the color for stroking operations using CMYK. The pen color is used when drawing lines and splines.

public Page SetPenColorCMYK(float c, float m, float y, float k)

Parameters

c float

the cyan component is float value from 0.0f to 1.0f.

m float

the magenta component is float value from 0.0f to 1.0f.

y float

the yellow component is float value from 0.0f to 1.0f.

k float

the black component is float value from 0.0f to 1.0f.

Returns

Page

this Page object.

SetPenWidth(float)

Sets the pen width that will be used to draw lines and splines on this page.

public Page SetPenWidth(float width)

Parameters

width float

the pen width.

Returns

Page

this Page object.

SetRotation(int)

Rotates this page clockwise when it is displayed, as every rotation in PDFjet turns and as /Rotate does, by 0, 90, 180 or 270 degrees; other angles are ignored.

public Page SetRotation(int degrees)

Parameters

degrees int

Returns

Page

SetStrokeDashPattern(string)

The stroke dash pattern controls the pattern of dashes and gaps used to stroke paths. It is specified by a dash array and a dash phase. The elements of the dash array are positive numbers that specify the lengths of alternating dashes and gaps. The dash phase specifies the distance into the dash pattern at which to start the dash. The elements of both the dash array and the dash phase are expressed in user space units.

Examples of line dash patterns:

    "[Array] Phase"     Appearance          Description
    _______________     _________________   ____________________________________

    "[] 0"              -----------------   Solid line
    "[3] 0"             ---   ---   ---     3 units on, 3 units off, ...
    "[2] 1"             -  --  --  --  --   1 on, 2 off, 2 on, 2 off, ...
    "[2 1] 0"           -- -- -- -- -- --   2 on, 1 off, 2 on, 1 off, ...
    "[3 5] 6"             ---     ---       2 off, 3 on, 5 off, 3 on, 5 off, ...
    "[2 3] 11"          -   --   --   --    1 on, 3 off, 2 on, 3 off, 2 on, ...
public Page SetStrokeDashPattern(string strokeDashPattern)

Parameters

strokeDashPattern string

the stroke dash pattern.

Returns

Page

this Page object.

SetTextRenderingMode(int)

Sets the text rendering mode.

public Page SetTextRenderingMode(int mode)

Parameters

mode int

the rendering mode.

Returns

Page

this Page object.

SetTextRotation(int)

Sets the rotation of the text that is drawn next. A positive angle turns clockwise, as every rotation in PDFjet turns, and a negative angle counterclockwise.

public Page SetTextRotation(int degrees)

Parameters

degrees int

the angle.

Returns

Page

this Page object.

SetTrimBox(float, float, float, float)

Sets the page TrimBox. See page 77 of the PDF32000_2008.pdf specification.

public Page SetTrimBox(float upperLeftX, float upperLeftY, float lowerRightX, float lowerRightY)

Parameters

upperLeftX float

the top left X coordinate of the TrimBox.

upperLeftY float

the top left Y coordinate of the TrimBox.

lowerRightX float

the bottom right X coordinate of the TrimBox.

lowerRightY float

the bottom right Y coordinate of the TrimBox.

Returns

Page

this Page object.

StrokePath()

Strokes the current path using the active pen color.

public void StrokePath()

Transform(float[])

Concatenates a transformation matrix to the current one. Save the graphics state before and restore it after. The page height is divided by the vertical scale.

public void Transform(float[] values)

Parameters

values float[]

the scale x, skew x, translate x, skew y, scale y and translate y at the MSCALE_X to MTRANS_Y indices, the first six values of an Android Matrix.getValues() array.