pdf-lib icon indicating copy to clipboard operation
pdf-lib copied to clipboard

How to use Chinese characters

Open KuiDaXElaina opened this issue 1 year ago • 1 comments

What were you trying to do?

I've encountered issues handling traditional Chinese PDF files while using PDFlib.

How did you attempt to do it?

When I drag a PDF file containing traditional Chinese into PDF-lib, the webpage displays an error, and the PDF file cannot be processed as expected. image

What actually happened?

I even tried to use ttf to directly load the entire glyph into js (Embed Font and Measure Text), but whenever the browser wanted to load ttf, it would pop up in violation of CORS regulations, but the magic is that using the official website (PDF- The ttf link provided by lib) does not violate the CORS regulations, but it still cannot be used. The ttf does not support Chinese. I have tried for a whole week, but I still haven’t solved the problem of PDF-lib processing Chinese.

And I found that PDF files processed with ttf have become fatter, from 9xKB to 13XX KB, which is too big.

What did you expect to happen?

Is there any chance for PDF lib to directly support Chinese processing? Whether it’s Traditional Chinese or Simplified Chinese

How can we reproduce the issue?

image 你好呀.pdf

Version

1.17.1

What environment are you running pdf-lib in?

Other

Checklist

  • [X] My report includes a Short, Self Contained, Correct (Compilable) Example.
  • [X] I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

KuiDaXElaina avatar Dec 10 '23 14:12 KuiDaXElaina

have a look at README https://github.com/Hopding/pdf-lib/tree/master?tab=readme-ov-file#fonts-and-unicode

AmilKey avatar Jan 22 '24 12:01 AmilKey