Node.js fontkit将pdf lib文本字段格式化错误
我试图在使用自定义字体的pdf中设置一些文本字段 当我设置文本字段的文本,然后嵌入自定义表单时,一些文本突然被分割。单词“loft et”突然变成了“loft et”。如果在创建pdf后单击文本字段,则会出现此显示。 这里是我加载字体的地方:Node.js fontkit将pdf lib文本字段格式化错误,node.js,zapier,Node.js,Zapier,我试图在使用自定义字体的pdf中设置一些文本字段 当我设置文本字段的文本,然后嵌入自定义表单时,一些文本突然被分割。单词“loft et”突然变成了“loft et”。如果在创建pdf后单击文本字段,则会出现此显示。 这里是我加载字体的地方: const fonturl3 = "http://localhost/pdflib-invoice/SourceSansPro-LightItalic.ttf"; const fontBytes3 = await fetch(f
const fonturl3 = "http://localhost/pdflib-invoice/SourceSansPro-LightItalic.ttf";
const fontBytes3 = await fetch(fonturl3).then((res) => res.arrayBuffer());
pdfDoc.registerFontkit(fontkit);
MessageFont = await pdfDoc.embedFont(fontBytes3);
let form = pdfDoc.getForm();
const textField = form.createTextField('Message');
let text = 'See here loftet, ser det ligesom nissen eller er det noget andet. \nDet her virker også. Det er jo vildt'
textField.setText(text);
textField.addToPage(page, {
width: 500,
height: 100,
x: 55,
y: 400,
borderWidth: 0
})
textField.enableRichFormatting();
textField.updateAppearances(MessageFont);
//textField.enableReadOnly();
console.log(MessageFont.encodeText(text));
// Serialize the PDFDocument to bytes (a Uint8Array)
const pdfBytes = await pdfDoc.save()```
When I enableReadOnly, the textfield is locked as it should, but some words looks wrong. Is there someway to "emulate" a click (which is my only idea), or is there anything else I can do?