foliojs / pdfkit

A JavaScript PDF generation library for Node and the browser

Home Page:http://pdfkit.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance 5x Slower PDFKit Document creation and unresponsive for CJK custom WOFF fonts.

Saranya-Sivanandham opened this issue · comments

Bug Report

Slow PDFKit Document creation and unresponsive, when WOFF type fonts are used.
No performance impact for the same font in TTF

Description of the problem

We are generating a text-only single-page PDF.
For languages Chinese, Hebrew & Japanese, we are making use of the below Google font in WOFF format downloaded from Google Webfonts helper.

Chinese - Noto Sans SC (1.5 MB) Download link Choose Historic support to get WOFF format.

Japanese / Hebrew - M PLUS 1p regular Download link Choose Historic support to get WOFF format.

For the above languages with the mentioned fonts, the pdf download takes around 8 seconds - 11 seconds for a single page.And it becomes unresponsive in Firefox. However, for other languages, it is way less ~ around 1 -2 seconds.

With TTF it works better without any issues

Note: Unable to upload woff font in GitHub. So shared the link from where I downloaded it.

Your environment

  • pdfkit version: 0.12.10
  • Node version: 18
  • Browser version (if applicable): Chrome Delay is seen but in Firefox it becomes unresponsive.
  • Operating System: Windows

@Saranya-Sivanandham ,I face the similar issue while using WOFF format.Sometimes its throw error. Better to use TTF font. It will work fine.

Can you post sample code that shows the difference?

You can fork https://replit.com/@blikblum/minimal-pdfkit or post a complete node script here