Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

garbled only in textField #3727

Open
luckymore opened this issue Apr 25, 2024 · 0 comments
Open

garbled only in textField #3727

luckymore opened this issue Apr 25, 2024 · 0 comments

Comments

@luckymore
Copy link

luckymore commented Apr 25, 2024

Enviroment: nodejsv20.12.1

I'm getting garbled Chinese when using textField, But it's normal in doc.text()

I've also tried Japanese and Russian and they are all garbled

import { jsPDF } from "jspdf";
import fs from "fs";

const doc = new jsPDF();

var SimSun = fs.readFileSync('./SimSun.ttf', {
  encoding: 'latin1',
});

doc.addFileToVFS('simsun.ttf', SimSun);
doc.addFont('simsun.ttf', 'simsun', 'normal');
doc.setFont('simsun');

const textField = new doc.AcroForm.TextField()
textField.Rect = [20, 20, 50, 50]
textField.value = '你好 世界! hello world!';
textField.fontStyle = 'normal';

doc.text(20, 20, '你好 世界! hello world!');
doc.addField(textField)

doc.save("hello.pdf")

enter image description here

#2677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant