pdf-lib-extended 1.0.43 → 1.0.45

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.43",
3
+ "version": "1.0.45",
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": {
@@ -376,8 +376,13 @@ class PDFLibExtended {
376
376
  * @param {number} padding - The amount of padding to add to the line
377
377
  * @returns {object} - An object containing the added space, the new X position, and the new Y position
378
378
  */
379
- nextLine(padding = 0) {
380
- const addedSpace = this.getTextSize() + padding;
379
+ nextLine(padding = null) {
380
+ const addedSpace = 0;
381
+ if(padding && !isNaN(Number(padding))) {
382
+ addedSpace += Number(padding);
383
+ }else{
384
+ addedSpace += this.getTextSize();
385
+ }
381
386
  this.getCurrentPage().moveTo(this.getMargin().left, this.getCurrentPage().getY() - addedSpace);
382
387
  return {
383
388
  addedSpace: addedSpace,
@@ -419,7 +424,7 @@ class PDFLibExtended {
419
424
  opacity: defaultOptions.opacity
420
425
  });
421
426
  if(defaultOptions.textDecoration === "underline"){
422
- this.pdf.drawLine({
427
+ this.getCurrentPage().drawLine({
423
428
  start: { x: this.getCurrentPage().getX(), y: this.getCurrentPage().getY() - 2 },
424
429
  end: { x: this.getCurrentPage().getX() + this.getCurrentFont().widthOfTextAtSize(text, defaultOptions.size), y: this.getCurrentPage().getY() - 2 },
425
430
  thickness: 1,
@@ -446,7 +451,7 @@ class PDFLibExtended {
446
451
  opacity: defaultOptions.opacity
447
452
  });
448
453
  if(defaultOptions.textDecoration === "underline"){
449
- this.pdf.drawLine({
454
+ this.getCurrentPage().drawLine({
450
455
  start: { x: xCenterPosition, y: this.getCurrentPage().getY() - 2 },
451
456
  end: { x: xCenterPosition + this.getCurrentFont().widthOfTextAtSize(text, defaultOptions.size), y: this.getCurrentPage().getY() - 2 },
452
457
  thickness: 1,
@@ -473,7 +478,7 @@ class PDFLibExtended {
473
478
  opacity: defaultOptions.opacity
474
479
  });
475
480
  if(defaultOptions.textDecoration === "underline"){
476
- this.pdf.drawLine({
481
+ this.getCurrentPage().drawLine({
477
482
  start: { x: xRightPosition, y: this.getCurrentPage().getY() - 2 },
478
483
  end: { x: xRightPosition + textWidth, y: this.getCurrentPage().getY() - 2 },
479
484
  thickness: 1,