npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pdfmake-rtl

v2.1.2

Published

Enhanced PDFMake with comprehensive RTL (Arabic/Persian/Urdu) support - Production ready package

Downloads

952

Readme

pdfmake-RTL Node.js CI GitHub npm

PDFMake RTL is an enhanced version of PDFMake with automatic RTL (Right-to-Left) language support for Arabic, Persian (Farsi), Urdu, and other RTL scripts. No manual configuration needed—just write your content and the library automatically detects and handles RTL text!

All existing PDFMake code works unchanged, with automatic RTL support added!

🚀 Key Features

  • Automatic RTL Detection - No need to set rtl flags
  • Smart Table Column Reversal - Arabic/Persian/Urdu tables automatically reverse columns
  • Unicode Script Detection - Supports Arabic, Persian, Urdu, and extensions
  • Automatic Font Selection - Uses appropriate fonts per language
  • Proper Text Alignment - RTL text aligns right, LTR text aligns left
  • List Bullet Positioning - Bullets positioned correctly for RTL lists
  • Mixed Content Support - Handles Arabic/Persian/Urdu/English mixed content
  • 100% PDFMake Compatible - Drop-in replacement for PDFMake

🌐 Live Demo

👉 View Live Demo on Netlify

PDF document generation library for server-side and client-side in pure JavaScript.

Check out the playground and examples.

documentation

For comprehensive guides, API references, and usage examples, visit the official documentation at pdfmake.github.io/docs.

Features

🔤 RTL Language Support

  • Automatic RTL detection for Arabic, Persian (Farsi), Urdu, and other RTL scripts
  • Smart table column reversal — columns automatically reverse for RTL content
  • Automatic font selection — uses Cairo font for Arabic, Persian, and Urdu text
  • Proper text alignment — RTL text automatically aligns right, LTR aligns left
  • List bullet positioning — bullets and numbers positioned correctly for RTL lists
  • Mixed content handling — seamlessly handles Arabic/Persian/Urdu/English in the same document
  • Unicode script detection — supports Arabic, Persian, Urdu characters and extensions

🗒️ Supported RTL Languages

| Language | Script | Auto Font | | ----------------- | ------- | --------- | | Arabic | العربية | Cairo | | Persian (Farsi) | فارسی | Cairo | | Urdu | اردو | Cairo | | Other RTL scripts | — | Cairo |

📄 General Features

  • line-wrapping,
  • text-alignments (left, right, centered, justified),
  • numbered and bulleted lists (with RTL-aware bullet positioning),
  • tables and columns
    • auto/fixed/star-sized widths,
    • col-spans and row-spans,
    • headers automatically repeated in case of a page-break,
    • automatic column reversal for RTL content,
  • images and vector graphics,
  • convenient styling and style inheritance,
  • page headers and footers:
    • static or dynamic content,
    • access to current page number and page count,
  • background-layer,
  • page dimensions and orientations,
  • margins,
  • document sections,
  • custom page breaks,
  • font embedding (Cairo font included for RTL support),
  • support for complex, multi-level (nested) structures,
  • table of contents,
  • helper methods for opening/printing/downloading the generated PDF,
  • setting of PDF metadata (e.g. author, subject).

📦 Installation

npm install pdfmake-rtl
```markdown

## ⚡ Quick Start — Browser (Client-Side)

```html
<!-- Load pdfmake-rtl + fonts -->
<script src="https://unpkg.com/pdfmake-rtl/build/pdfmake.min.js"></script>
<script src="https://unpkg.com/pdfmake-rtl/build/vfs_fonts.js"></script>
<!-- <script src="https://unpkg.com/pdfmake-rtl/build/fonts/Cairo.js"></script> -->

<script>
	var dd = {
		rtl: true,
		// If Cairo font isn't applied automatically, set `rtl: true` to force RTL mode or add defaultStyle:{font:'Cairo'}
		content: [
			// RTL paragraph — auto-detected, no configuration needed
			{ text: "مرحباً بكم في مكتبة pdfmake-rtl", fontSize: 20, bold: true },
			{
				text: "هذه المكتبة تدعم اللغة العربية تلقائياً",
				margin: [0, 0, 0, 15],
			},

			// RTL table — columns auto-reverse for Arabic content
			{
				table: {
					// rtl:true
					widths: ["*", "*", "*"],
					body: [
						[
							{ text: "الراتب", bold: true },
							{ text: "القسم", bold: true },
							{ text: "الاسم", bold: true },
						],
						["5000", "تكنولوجيا", "أحمد محمد"],
						["6000", "تسويق", "فاطمة علي"],
					],
				},
			},

			// Force RTL on any table with rtl: true
			{
				table: {
					rtl: true,
					widths: ["*", "*", "*"],
					body: [
						[
							{ text: "Status", bold: true },
							{ text: "Name", bold: true },
							{ text: "#", bold: true },
						],
						["Active", "Ali Hassan", "1"],
						["Active", "Sara Ahmed", "2"],
					],
				},
			},
		],
	};

	pdfMake.createPdf(dd).open();
</script>

📄 See the full working example: examples/simple-rtl-table.html

⚡ Quick Start — Node.js (Server-Side)

var pdfmake = require("pdfmake-rtl");

// Add fonts
// Cairo is the default font for RTL languages (Arabic, Persian, Urdu)
// Roboto is the default font for LTR/Latin text
var Roboto = require("pdfmake-rtl/fonts/Roboto");
pdfmake.addFonts(Roboto);

var Cairo = require("pdfmake-rtl/fonts/Cairo");
pdfmake.addFonts(Cairo);

var dd = {
	// If Cairo font isn't applied automatically, set `rtl: true` to force RTL mode or add defaultStyle Cairo
	rtl: true, // Forces RTL layout direction for the entire document
	content: [
		{ text: "مرحباً بكم في مكتبة pdfmake-rtl", fontSize: 20, bold: true },
		{
			table: {
				widths: ["*", "*", "*"],
				body: [
					[
						{ text: "الراتب", bold: true },
						{ text: "القسم", bold: true },
						{ text: "الاسم", bold: true },
					],
					["5000", "تكنولوجيا", "أحمد محمد"],
					["6000", "تسويق", "فاطمة علي"],
				],
			},
		},
	],
};

var pdf = pdfmake.createPdf(dd);
pdf.write("output.pdf").then(() => console.log("PDF created!"));

Building from sources

using npm:

git clone https://github.com/aysnet1/pdfmake-rtl.git
cd pdfmake-rtl
npm install
npm run build

using yarn:

git clone https://github.com/aysnet1/pdfmake-rtl.git
cd pdfmake-rtl
yarn
yarn run build

License

MIT

Credits

pdfmake-rtl

pdfmake (Original Library)

pdfmake is based on a truly amazing library pdfkit (credits to @devongovett).

Thanks to all contributors.