MCPcopy Create free account
hub / github.com/LibPDF-js/core / setRect

Method setRect

src/annotations/base.ts:111–132  ·  view source on GitHub ↗

* Set the annotation rectangle.

(rect: Rect)

Source from the content-addressed store, hash-verified

109 * Set the annotation rectangle.
110 */
111 setRect(rect: Rect): void {
112 const arr = this.dict.getArray("Rect", this.registry.resolve.bind(this.registry));
113
114 if (arr && arr.length >= 4) {
115 arr.set(0, PdfNumber.of(rect.x));
116 arr.set(1, PdfNumber.of(rect.y));
117 arr.set(2, PdfNumber.of(rect.x + rect.width));
118 arr.set(3, PdfNumber.of(rect.y + rect.height));
119 } else {
120 this.dict.set(
121 "Rect",
122 new PdfArray([
123 PdfNumber.of(rect.x),
124 PdfNumber.of(rect.y),
125 PdfNumber.of(rect.x + rect.width),
126 PdfNumber.of(rect.y + rect.height),
127 ]),
128 );
129 }
130
131 this.markModified();
132 }
133
134 /**
135 * Text content or description of the annotation.

Callers

nothing calls this directly

Calls 4

markModifiedMethod · 0.95
getArrayMethod · 0.80
setMethod · 0.45
ofMethod · 0.45

Tested by

no test coverage detected