pdf-lib-extended 1.0.12 → 1.0.14

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.12",
3
+ "version": "1.0.14",
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": {
@@ -474,6 +474,7 @@ class PDFLibExtended {
474
474
  size: this.getTextSize(),
475
475
  color: this.getColor(),
476
476
  opacity: 1,
477
+ padding: 0,
477
478
  ...options
478
479
  };
479
480
  if(options.range) this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
@@ -498,7 +499,7 @@ class PDFLibExtended {
498
499
  });
499
500
 
500
501
  // Move to the next line
501
- this.nextLine();
502
+ this.nextLine(defaultOptions.padding);
502
503
  this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
503
504
  currentLine = "";
504
505
  currentWidth = 0;
@@ -608,7 +609,7 @@ class PDFLibExtended {
608
609
  }
609
610
 
610
611
  if(defaultOptions.newLine){
611
- this.nextLine();
612
+ this.nextLine(defaultOptions.padding);
612
613
  page.moveTo(page.getX(), y - Number(defaultOptions.height) - change - defaultOptions.size - defaultOptions.padding);
613
614
  }
614
615
  else page.moveTo(x + width + defaultOptions.padding, y - defaultOptions.size);
@@ -710,6 +711,7 @@ class PDFLibExtended {
710
711
  color: this.getColor(),
711
712
  size: this.getTextSize(),
712
713
  indent: false,
714
+ padding: 0,
713
715
  ...options,
714
716
  }
715
717
  if (defaultOptions.range && !parser) this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
@@ -722,7 +724,7 @@ class PDFLibExtended {
722
724
  switch (node.nodeName) {
723
725
  case "P":
724
726
  this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY() - defaultOptions.margin);
725
- this.nextLine();
727
+ this.nextLine(defaultOptions.padding);
726
728
  this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
727
729
  break;
728
730
  case "STRONG":
@@ -736,7 +738,7 @@ class PDFLibExtended {
736
738
  case "UL":
737
739
  break;
738
740
  case "LI":
739
- this.nextLine();
741
+ this.nextLine(defaultOptions.padding);
740
742
  this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
741
743
  this.getCurrentPage().moveRight(this.getCurrentNodes().filter(value => value === "UL").length * this.getMargin().left);
742
744
  this.drawText("• ", { size: defaultOptions.size, color: defaultOptions.color });
@@ -755,7 +757,7 @@ class PDFLibExtended {
755
757
  });
756
758
  tableData.push(tableRow);
757
759
  });
758
- this.nextLine();
760
+ this.nextLine(defaultOptions.padding);
759
761
  this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
760
762
  this.drawTable(tableHead, tableData, {
761
763
  range: {left: defaultOptions.range.left, right: defaultOptions.range.right},
@@ -785,7 +787,7 @@ class PDFLibExtended {
785
787
  string += " ";
786
788
  let wordWidth = this.getCurrentFont().widthOfTextAtSize(string, defaultOptions.size);
787
789
  if(wordWidth + this.getCurrentPage().getX() >= maxWidth){
788
- this.nextLine();
790
+ this.nextLine(defaultOptions.padding);
789
791
  this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY());
790
792
  }
791
793
  this.drawText(string, {