pdf-lib-extended 1.0.46 → 1.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/PDFLibExtended.js +13 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-lib-extended",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
4
4
|
"description": "This project extends the capabilities of the pdf-lib JavaScript library by providing a set of helper functions that simplify common PDF manipulation tasks. It includes utilities for drawing and formatting text, images, and shapes within PDF documents, allowing for more advanced customization and automation. The class-based architecture, designed as a toolkit, ensures that developers can easily integrate these enhanced features into their existing workflows. With this extension, users can streamline the creation of dynamic and complex PDFs with minimal effort.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
package/src/PDFLibExtended.js
CHANGED
|
@@ -532,6 +532,7 @@ class PDFLibExtended {
|
|
|
532
532
|
|
|
533
533
|
let currentLine = "";
|
|
534
534
|
let currentWidth = 0;
|
|
535
|
+
let biggestWidth = 0;
|
|
535
536
|
let totalHeight = defaultOptions.size;
|
|
536
537
|
|
|
537
538
|
tokens.forEach((tok, i) => {
|
|
@@ -558,27 +559,30 @@ class PDFLibExtended {
|
|
|
558
559
|
this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
|
|
559
560
|
currentLine = tok; // start new line with the token (no leading space)
|
|
560
561
|
currentWidth = this.getCurrentFont().widthOfTextAtSize(tok, defaultOptions.size);
|
|
562
|
+
if(currentWidth > biggestWidth) biggestWidth = currentWidth;
|
|
561
563
|
} else {
|
|
562
564
|
// Safe to add to this line
|
|
563
565
|
currentLine += piece;
|
|
564
566
|
currentWidth += pieceWidth;
|
|
567
|
+
if(currentWidth > biggestWidth) biggestWidth = currentWidth;
|
|
565
568
|
}
|
|
566
569
|
|
|
567
570
|
// Last token: flush
|
|
568
571
|
if (i === tokens.length - 1 && currentLine) {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
572
|
+
this.drawText(currentLine, {
|
|
573
|
+
size: defaultOptions.size,
|
|
574
|
+
color: defaultOptions.color,
|
|
575
|
+
opacity: defaultOptions.opacity,
|
|
576
|
+
align: defaultOptions.align,
|
|
577
|
+
range: defaultOptions.range,
|
|
578
|
+
textDecoration: defaultOptions.textDecoration
|
|
579
|
+
});
|
|
577
580
|
}
|
|
578
581
|
});
|
|
579
582
|
|
|
580
583
|
return {
|
|
581
|
-
height: totalHeight
|
|
584
|
+
height: totalHeight,
|
|
585
|
+
width: biggestWidth
|
|
582
586
|
};
|
|
583
587
|
}
|
|
584
588
|
|