pdf-lib-extended 1.0.14 → 1.0.15

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.14",
3
+ "version": "1.0.15",
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": {
@@ -475,6 +475,8 @@ class PDFLibExtended {
475
475
  color: this.getColor(),
476
476
  opacity: 1,
477
477
  padding: 0,
478
+ wordWrap: true,
479
+ characterWrap: false,
478
480
  ...options
479
481
  };
480
482
  if(options.range) this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
@@ -483,7 +485,11 @@ class PDFLibExtended {
483
485
  let currentWidth = 0;
484
486
  let currentLine = "";
485
487
 
486
- text = text.split(" ");
488
+ if(wordWrap){
489
+ text = text.split(" ");
490
+ }else{
491
+ text = text.split("");
492
+ }
487
493
 
488
494
  text.forEach((string, i) => {
489
495
  let wordWidth = this.getCurrentFont().widthOfTextAtSize(string, defaultOptions.size);
@@ -505,7 +511,9 @@ class PDFLibExtended {
505
511
  currentWidth = 0;
506
512
  }
507
513
 
508
- currentLine += string + " ";
514
+ if(wordWrap){
515
+ currentLine += string + " ";
516
+ }
509
517
  currentWidth += wordWidth;
510
518
 
511
519
  // If it's the last word, draw the remaining line