Skip to content

Commit 9d7245f

Browse files
authored
🤖 Merge PR DefinitelyTyped#73311 [@types/pdfkit] add boundsOfString by @m4rvr
1 parent 5216a95 commit 9d7245f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

types/pdfkit/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,13 @@ declare namespace PDFKit.Mixins {
577577
structTypes?: [string | null, string | null, string | null] | undefined;
578578
}
579579

580+
interface TextBounds {
581+
x: number;
582+
y: number;
583+
width: number;
584+
height: number;
585+
}
586+
580587
interface PDFText {
581588
lineGap(lineGap: number): this;
582589
moveDown(line?: number): this;
@@ -585,6 +592,8 @@ declare namespace PDFKit.Mixins {
585592
text(text: string, options?: TextOptions): this;
586593
widthOfString(text: string, options?: TextOptions): number;
587594
heightOfString(text: string, options?: TextOptions): number;
595+
boundsOfString(text: string, x?: number, y?: number, options?: TextOptions): TextBounds;
596+
boundsOfString(text: string, options?: TextOptions): TextBounds;
588597
list(list: Array<string | any>, x?: number, y?: number, options?: TextOptions): this;
589598
list(list: Array<string | any>, options?: TextOptions): this;
590599
}

types/pdfkit/pdfkit-tests.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,3 +712,13 @@ const optionalPDF: PDFKit.PDFDocument = new PDFDocument({
712712

713713
// Test outlines
714714
doc.outline.addItem("A");
715+
716+
// $ExpectType TextBounds
717+
doc.boundsOfString("Bounds of string", 50, 100, {
718+
align: "left",
719+
});
720+
721+
// $ExpectType TextBounds
722+
doc.boundsOfString("Bounds of string", {
723+
align: "left",
724+
});

0 commit comments

Comments
 (0)