pdf-lib-extended 1.0.41 → 1.0.42

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdf-lib-extended",
3
- "version": "1.0.41",
3
+ "version": "1.0.42",
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": {
@@ -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