pdf-lib-extended 1.0.41 → 1.0.43
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 +33 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-lib-extended",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
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
|
@@ -407,6 +407,7 @@ class PDFLibExtended {
|
|
|
407
407
|
size: this.getTextSize(),
|
|
408
408
|
color: this.getColor(),
|
|
409
409
|
opacity: 1,
|
|
410
|
+
textDecoration: null,
|
|
410
411
|
...options,
|
|
411
412
|
};
|
|
412
413
|
|
|
@@ -417,6 +418,15 @@ class PDFLibExtended {
|
|
|
417
418
|
color: defaultOptions.color,
|
|
418
419
|
opacity: defaultOptions.opacity
|
|
419
420
|
});
|
|
421
|
+
if(defaultOptions.textDecoration === "underline"){
|
|
422
|
+
this.pdf.drawLine({
|
|
423
|
+
start: { x: this.getCurrentPage().getX(), y: this.getCurrentPage().getY() - 2 },
|
|
424
|
+
end: { x: this.getCurrentPage().getX() + this.getCurrentFont().widthOfTextAtSize(text, defaultOptions.size), y: this.getCurrentPage().getY() - 2 },
|
|
425
|
+
thickness: 1,
|
|
426
|
+
color: defaultOptions.color,
|
|
427
|
+
opacity: defaultOptions.opacity
|
|
428
|
+
});
|
|
429
|
+
}
|
|
420
430
|
break;
|
|
421
431
|
|
|
422
432
|
case "center":
|
|
@@ -435,6 +445,15 @@ class PDFLibExtended {
|
|
|
435
445
|
color: defaultOptions.color,
|
|
436
446
|
opacity: defaultOptions.opacity
|
|
437
447
|
});
|
|
448
|
+
if(defaultOptions.textDecoration === "underline"){
|
|
449
|
+
this.pdf.drawLine({
|
|
450
|
+
start: { x: xCenterPosition, y: this.getCurrentPage().getY() - 2 },
|
|
451
|
+
end: { x: xCenterPosition + this.getCurrentFont().widthOfTextAtSize(text, defaultOptions.size), y: this.getCurrentPage().getY() - 2 },
|
|
452
|
+
thickness: 1,
|
|
453
|
+
color: defaultOptions.color,
|
|
454
|
+
opacity: defaultOptions.opacity
|
|
455
|
+
});
|
|
456
|
+
}
|
|
438
457
|
this.getCurrentPage().moveTo(currentPositionCenter.x, currentPositionCenter.y);
|
|
439
458
|
break;
|
|
440
459
|
|
|
@@ -453,6 +472,15 @@ class PDFLibExtended {
|
|
|
453
472
|
color: defaultOptions.color,
|
|
454
473
|
opacity: defaultOptions.opacity
|
|
455
474
|
});
|
|
475
|
+
if(defaultOptions.textDecoration === "underline"){
|
|
476
|
+
this.pdf.drawLine({
|
|
477
|
+
start: { x: xRightPosition, y: this.getCurrentPage().getY() - 2 },
|
|
478
|
+
end: { x: xRightPosition + textWidth, y: this.getCurrentPage().getY() - 2 },
|
|
479
|
+
thickness: 1,
|
|
480
|
+
color: defaultOptions.color,
|
|
481
|
+
opacity: defaultOptions.opacity
|
|
482
|
+
});
|
|
483
|
+
}
|
|
456
484
|
this.getCurrentPage().moveTo(currentPositionRight.x, currentPositionRight.y);
|
|
457
485
|
break;
|
|
458
486
|
|
|
@@ -485,6 +513,7 @@ class PDFLibExtended {
|
|
|
485
513
|
padding: 0, // extra spacing between lines
|
|
486
514
|
wordWrap: true,
|
|
487
515
|
characterWrap: false,
|
|
516
|
+
textDecoration: null,
|
|
488
517
|
...options
|
|
489
518
|
};
|
|
490
519
|
|
|
@@ -515,7 +544,8 @@ class PDFLibExtended {
|
|
|
515
544
|
color: defaultOptions.color,
|
|
516
545
|
opacity: defaultOptions.opacity,
|
|
517
546
|
align: defaultOptions.align,
|
|
518
|
-
range: defaultOptions.range
|
|
547
|
+
range: defaultOptions.range,
|
|
548
|
+
textDecoration: defaultOptions.textDecoration
|
|
519
549
|
});
|
|
520
550
|
let nextLineData = this.nextLine(defaultOptions.padding);
|
|
521
551
|
totalHeight += nextLineData.addedSpace;
|
|
@@ -536,7 +566,8 @@ class PDFLibExtended {
|
|
|
536
566
|
color: defaultOptions.color,
|
|
537
567
|
opacity: defaultOptions.opacity,
|
|
538
568
|
align: defaultOptions.align,
|
|
539
|
-
range: defaultOptions.range
|
|
569
|
+
range: defaultOptions.range,
|
|
570
|
+
textDecoration: defaultOptions.textDecoration
|
|
540
571
|
});
|
|
541
572
|
}
|
|
542
573
|
});
|