pdf-lib-extended
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "pdf-lib-extended", | ||
"version": "1.0.3", | ||
"version": "1.0.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,0 +5,0 @@ "main": "index.js", |
@@ -705,3 +705,2 @@ import { degrees, PDFDocument, rgb, StandardFonts } from 'pdf-lib'; | ||
margin: 8, | ||
indent: 0, // New indent option for the first line | ||
range: { | ||
@@ -716,5 +715,5 @@ left: this.getMargin().left, | ||
} | ||
if (defaultOptions.range && !parser) this.getCurrentPage().moveTo(defaultOptions.range.left + defaultOptions.indent, this.getCurrentPage().getY()); | ||
if (defaultOptions.range && !parser) this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY()); | ||
let maxWidth = defaultOptions.range.right; | ||
if(nodes.length > 0){ | ||
@@ -726,3 +725,3 @@ for(let node of nodes){ | ||
case "P": | ||
this.getCurrentPage().moveTo(defaultOptions.range.left + defaultOptions.indent, this.getCurrentPage().getY() - defaultOptions.margin); | ||
this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY() - defaultOptions.margin); | ||
this.nextLine(); | ||
@@ -745,4 +744,4 @@ this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY()); | ||
this.getCurrentPage().moveRight(this.getCurrentNodes().filter(value => value === "UL").length * this.getMargin().left); | ||
this.drawText("\u2022 ", { size: defaultOptions.size, color: defaultOptions.color }); | ||
this.getCurrentPage().moveRight(this.getCurrentFont().widthOfTextAtSize("\u2022 ", defaultOptions.size)); | ||
this.drawText("• ", { size: defaultOptions.size, color: defaultOptions.color }); | ||
this.getCurrentPage().moveRight(this.getCurrentFont().widthOfTextAtSize("• ", defaultOptions.size)); | ||
break; | ||
@@ -774,5 +773,5 @@ case "TABLE": | ||
} | ||
if(node.nodeName === "TABLE") break; | ||
this.htmlParser(node, parser, defaultOptions); | ||
@@ -784,3 +783,2 @@ } | ||
let splitText = text.data.split(" "); | ||
let isFirstWord = true; | ||
splitText.forEach(string => { | ||
@@ -792,9 +790,3 @@ string += " "; | ||
this.getCurrentPage().moveTo(defaultOptions.range.left, this.getCurrentPage().getY()); | ||
isFirstWord = false; | ||
} | ||
// Apply indent only for the first line | ||
if(isFirstWord && defaultOptions.indent > 0) { | ||
this.getCurrentPage().moveRight(defaultOptions.indent); | ||
isFirstWord = false; | ||
} | ||
this.drawText(string, { | ||
@@ -806,3 +798,3 @@ size: defaultOptions.size, | ||
}); | ||
/*** REMOVE STYLINGS ***/ | ||
@@ -814,3 +806,3 @@ this.checkParentHTML(text); | ||
} | ||
/** | ||
@@ -817,0 +809,0 @@ * |
39546
859