rkusa / pdfjs

A Portable Document Format (PDF) generation library targeting both the server- and client-side.
MIT License
774 stars 142 forks source link

Error: Using spaces or \t at the beginning of a line when using Chinese will result in no line breaks #302

Closed Hyperi0n888 closed 1 year ago

Hyperi0n888 commented 1 year ago

import * as pdfjs from "pdfjs";

const doc = new pdfjs.Document({ fontSize: 12, lineHeight: 1.5, paddingTop: 20 pdfjs.mm, paddingBottom: 20 pdfjs.mm, paddingLeft: 31.8 pdfjs.mm, paddingRight: 31.8 pdfjs.mm, }) doc.cell(' 你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好')

Hyperi0n888 commented 1 year ago

I solved the problem by simply adding \u200B to the beginning of the text, but I don't know why it's like that and I'd like an answer

doc.cell('  \u200B你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好你好')