使用 JavaScript 将数字转换为 PDF 格式的单词

问题描述

当我在 Foxit Reader 的 PDF 表单中使用 Salman 在 Convert digits into words with JavaScript 中提到的代码 - 自定义计算脚本时,它不起作用,当我看到控制台时,它说:

======== Field : calculate ========
[ Line: 00015 { ReferenceError } ] : document is not defined

我需要修改什么才能让它以 PDF 格式工作?

解决方法

你显然需要更改代码

document.getElementById('number').onkeyup = function () {
    document.getElementById('words').innerHTML = inWords(document.getElementById('number').value);
};

相当于foxit

类似的东西

this.getField ("words").value = inWords(this.getField("number").value)

https://www.foxitsoftware.com/blog/how-to-create-forms-that-perform-simple-mathematical-calculations/

https://developers.foxitsoftware.com/kb/article/javascript-pdf-sdk-java/

https://www.foxitsoftware.com/blog/how-to-add-javascript-functionality-to-pdf-forms-without-coding/