![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
pdf-lib-extended
Advanced tools
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, all
PDF-lib-Extended is a JavaScript library that extends the functionality of the popular pdf-lib library. This extension adds several useful methods for working with PDF documents, making it easier to manipulate text, images, tables, and other elements within your PDFs.
To install PDF-lib-Extended, use npm:
npm install pdf-lib-extended
Here’s a basic example of how to use PDF-lib-Extended in your project:
import PDFExtended from 'pdf-lib-extended';
async function createPDF() {
const pdf = new PDFExtended();
await pdf.init();
// Add a new page
pdf.addNewPage();
// Draw some text
pdf.drawText('Hello, World!', {
align: 'center',
size: 24,
color: pdf.getColor(),
});
// Draw a circle with text inside
pdf.drawCircleText(100, 100, 'A', {
size: 12,
color: pdf.getColor(),
});
// Generate and download the PDF
const pdfUrl = await pdf.generatePDFURL();
window.open(pdfUrl);
}
createPDF();
PDF-lib-Extended includes several custom methods to enhance your PDF creation experience:
Text Handling:
drawText(text, options)
: Draws text on the current page with alignment, color, and size options.drawParagraph(text, options)
: Automatically wraps text to the next line within specified bounds.Shape Drawing:
drawCircleText(x, y, text, options)
: Draws a circle with text centered inside.Tables:
drawTable(header, data, options)
: Draws a table with customizable borders, alignment, and size.Images:
addImage(x, y, base64Image, imageScale)
: Adds an image to the PDF document at specified coordinates with optional scaling.Watermarks:
drawWatermark(text, size)
: Draws a watermark on each page of the document.Document Management:
addNewPage(dimensions)
: Adds a new page to the PDF document.fetchPDF(url)
: Fetches an existing PDF from a URL and loads it into the document.mergePDF(urls)
: Merges multiple PDFs from URLs into the current document.HTML Parsing:
htmlParser(text, parser, options)
: Parses HTML and draws it on the PDF.init()
Initializes the PDF document and embeds fonts.
setTextSize(number)
Sets the text size for the document.
setCircleScale(number)
Sets the scale for circles drawn on the document.
setMargin(arr)
Sets the margins for the document.
setCurrentPage(page)
Sets the current page of the document.
setColor(color)
Sets the color for text and shapes.
getPDF()
Returns the current PDF document instance.
generatePDFURL()
Generates a URL for downloading the PDF document.
drawText(text, options)
Draws text on the current page.
drawCircleText(x, y, text, options)
Draws a circle with text centered inside.
drawTable(header, data, options)
Draws a table with the specified header and data.
addImage(x, y, base64Image, imageScale)
Adds an image to the PDF document.
drawWatermark(text, size)
Draws a watermark on each page of the document.
If you find a bug or have a feature request, feel free to open an issue or submit a pull request. Contributions are welcome!
This project is licensed under the MIT License.
FAQs
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, all
The npm package pdf-lib-extended receives a total of 2 weekly downloads. As such, pdf-lib-extended popularity was classified as not popular.
We found that pdf-lib-extended demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.