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, Embed Image & Text in Node.js.
What is HummusJS Library ?
In modern software development, having a powerful PDF Node.js API can significantly improve your application's efficiency and flexibility. HummusJS is an open-source library that enables developers to create PDF files in Node.js, read PDF files, and perform advanced tasks with ease. With a clean and approachable API, HummusJS allows you to create a new PDF in Node.js, embed images in PDF, merge multiple documents, and add or edit content—all with just a few lines of code. Its simplicity makes it ideal for developers who want quick integration without deep dives into the PDF specification.
One standout feature of HummusJS is its ability to manage fonts in PDF documents, including the option to use custom fonts in PDF files, ensuring full control over styling and layout. Whether you're merging PDF files in Node.js, injecting dynamic text, or embedding assets, the library handles both small and large documents with impressive speed and stability. Its efficient architecture and developer-friendly design make HummusJS a reliable choice for anyone looking to streamline PDF handling in their Node.js projects.
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();