How can I help you?
PdfPen
16 Mar 20264 minutes to read
Represents a pen for the PDF page.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data, password);
// Access first page
let page: PdfPage = document.getPage(0);
// Gets the graphics of the PDF page
let graphics: PdfGraphics = page.graphics;
// Create a new pen
let pen: PdfPen = new PdfPen({r: 0, g: 0, b: 0}, 1);
// Draw a rectangle using pen
graphics.drawRectangle({x: 150, y: 50, width: 50, height: 50}, pen);
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();Properties
Get color PdfColor
Gets the pen color used for drawing.
Set color void
Sets the pen color used for drawing.
| Parameter | Type | Description |
|---|---|---|
| value | PdfColor |
The color to use for the pen. |
Get dashOffset number
Gets the dash phase offset that shifts where the dash pattern begins. Measured in points.
Set dashOffset void
Sets the dash phase offset that determines where the dash pattern begins. Measured in points.
| Parameter | Type | Description |
|---|---|---|
| value | number |
The dash offset in points. |
Get dashPattern number[]
Gets the dash pattern array specifying alternating dash and gap lengths in points.
Set dashPattern void
Sets the dash pattern array specifying alternating dash and gap lengths in points.
| Parameter | Type | Description |
|---|---|---|
| value | number[] |
Array of numbers representing dash and gap lengths. |
Get dashStyle PdfDashStyle
Gets the dash style of the pen.
Set dashStyle void
Sets the dash style of the pen.
| Parameter | Type | Description |
|---|---|---|
| value | PdfDashStyle |
The dash style to apply. |
Get lineCap PdfLineCap
Gets the line cap style applied to the ends of lines.
Set lineCap void
Sets the line cap style applied to the ends of lines.
| Parameter | Type | Description |
|---|---|---|
| value | PdfLineCap |
The line cap style. |
Get lineJoin PdfLineJoin
Gets the line join style used at intersections between line segments.
Set lineJoin void
Sets the line join style used at intersections between line segments.
| Parameter | Type | Description |
|---|---|---|
| value | PdfLineJoin |
The line join style to set. |
Get miterLimit number
Gets the miter limit value, used when lineJoin is Miter.
Set miterLimit void
Sets the miter limit for mitered line joins.
| Parameter | Type | Description |
|---|---|---|
| value | number |
The miter limit value. |
Get width number
Gets the width of the pen.
Set width void
Sets the width of the pen.
| Parameter | Type | Description |
|---|---|---|
| value | number |
The pen width in points. |