Free Node.js Library to Create, Edit & Merge PDF Files
A Powerful Node.js PDF Library Designed for High-Performance that Povides a Set of High-Level APIs for Creating, Reading, Merging, Editing, and Manipulating PDF Files in Node.js.
What is HummusJS Library ?
Having robust and efficient libraries at your disposal can significantly improve the caliber of your software development projects. HummusJS is one such library that has recently gained popularity. This library, which provides a variety of high-quality tools for working with PDF files in a Node.js environment, is renowned for being both robust and adaptable. Being open-source implies that anybody can access, alter, and share the library's source code without restriction.
Software developers like you can manage PDF files with ease and without the hassles thanks to the HummusJS library, which makes it simple for them to get started with little work. Creating, modifying, parsing, and merging PDFs, as well as adding text and graphics, are made easier using this tool's user-friendly API. You may easily conduct a variety of functions on PDF files with only a few lines of code. In addition to saving time, streamlining your workflow enables developers to focus on coming up with fresh concepts rather than becoming bogged down in technical details.
One more thing that’s really great about the open-source HummusJS library is how well it performs. It’s made to be quick and trustworthy, thanks to clever algorithms and data setups. Whether you’re working on small files or big documents, it handles tasks fast and well. This makes it a solid choice for projects needing speedy and efficient PDF edits.
Getting Started with HummusJS
The best way to install HummusJS library is via npm, please use the following command for smoothly installing the library.
Install HummusJS Library via npm
Install HummusJS Library via npm
You can also download the library directly from GitHUb HummusJS product page
PDF Creation & Editing in Node.js
The open source HummusJS library allows for the creation of new PDF documents from scratch inside Node.js apps with just a couple of lines of code. This feature is particularly useful for generating reports, invoices, and other documents dynamically. The library also supports modifying existing PDFs, such as adding new content, merging PDFs, and even altering the structure of the document. The following example shows how software developers can create a new PDF documents inside Node.js applications.
How to Create a New PDF File inside Node.js Apps?
const hummus = require('hummus');
const pdfWriter = hummus.createWriter('output.pdf');
const page = pdfWriter.createPage(0, 0, 595, 842); // A4 size
pdfWriter.startPageContentContext(page)
.writeText(
'Hello, HummusJS!',
100, 800,
{ font: pdfWriter.getFontForFile('Arial.ttf'), size: 12, colorspace: 'gray', color: 0x00 }
);
pdfWriter.writePage(page);
pdfWriter.end();
Embedding Images to PDF in Node.js
Embedding images as well as text in PDF documents is a straightforward task with HummusJS library. This feature is very useful for adding logos, signatures, or any other graphical content inside PDFs. The library is very easy to handle and supports various image formats, including JPEG, GIF, and PNG, allowing for rich visual content in your PDF documents. Here is a very useful code example that shows how software developers can embed an image in a PDF file inside Node.js environment.
How to Embed an Image inside PDF Documents via Node.js Library?
const pdfWriter = hummus.createWriter('image.pdf');
const page = pdfWriter.createPage(0, 0, 595, 842);
const context = pdfWriter.startPageContentContext(page);
context.drawImage(50, 700, 'path/to/image.jpg', {
transformation: { width: 200, height: 200 }
});
pdfWriter.writePage(page).end();
Merging PDF Documents in Node.js Apps
Merging several PDFs into a single document is a common requirement in many applications. The open source HummusJS library has provided complete functionality for merging multiple PDF documents into a single file inside Node.js Apps. This features is very useful for combining multiple reports, portfolios, or any collection of PDF documents. The library simplifies this process, making it easy to combine multiple PDF files as shown in the following code example.
How to Merge Multiple PDF Documents inside Node.js ?
const hummus = require('hummus');
const pdfWriter = hummus.createWriter('merged.pdf');
pdfWriter.appendPDFPagesFromPDF('file1.pdf');
pdfWriter.appendPDFPagesFromPDF('file2.pdf');
pdfWriter.end();
Manage Text and Font in PDFs
With HummusJS library, software developers can manage text and fonts with great precision inside JavaScript Apps. The library provides robust text and font handling capabilities, enabling the inclusion of various fonts and precise text placement within PDF documents. This capability is essential for creating documents with varied typography and customized text placements. Here is an example that how software developers can use custom fonts inside their PDF documents inside Node.js.
How to Use Custom Fonts inside PDF Documents via Node.js Library?
const hummus = require('hummus');
const pdfWriter = hummus.createWriter('custom_font.pdf');
const page = pdfWriter.createPage(0, 0, 595, 842);
pdfWriter.startPageContentContext(page)
.writeText(
'Custom Font Example',
100, 700,
{ font: pdfWriter.getFontForFile('CustomFont.ttf'), size: 16, colorspace: 'gray', color: 0x00 }
);
pdfWriter.writePage(page);
pdfWriter.end();