jspdf-fontkit
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

NPM Version npm bundle size NPM Type Definitions

jspdf-fontkit

jsPDF with fontkit for complex glyph support

Why?

jsPDF is one of the best libraries for generating PDFs in the browser as well as on the server. However, it lacks full support for complex glyphs like Indic scripts. If you try to generate a PDF with these scripts, you may see the characters are not rendered correctly (check this GitHub issue).

This is where jspdf-fontkit comes in. It uses fontkit to load fonts and convert them to a format that jsPDF can use which allows for full support of complex glyphs.

It also applies a patch to to fontkit to fix a rendering issue with Bengali script.

Installation

npm install jspdf-fontkit

Usage

You can use jspdf-fontkit the same way you would use jsPDF. Just import it from 'jspdf-fontkit' instead of 'jspdf'.

import jsPDF from 'jspdf-fontkit';

Development

Clone the repository recursively (as fontkit and jsPDF are submodules):

git clone --recursive git@github.com:rafiibrahim8/jspdf-fontkit.git
cd jspdf-fontkit

You need to apply the patch that will modify jsPDF to use fontkit. To do this, run the following command:

patch -p1 < submodules.patch

Then, install the dependencies:

pnpm install 

Note: This repo uses pnpm workspaces to manage dependencies. So, npm or yarn might not work as expected.

To build the library:

pnpm build

You will find the built files in the packages/jspdf-fontkit/lib directory.

Readme

Keywords

Package Sidebar

Install

npm i jspdf-fontkit

Weekly Downloads

15

Version

0.0.7

License

MIT

Unpacked Size

1.87 MB

Total Files

6

Last publish

Collaborators

  • rafiibrahim8