[英]How to edit Font Size for TextField() in JSPDF?
Good morning, Has anyone been able to edit the font size on a TextField()
in JSPDF?早上好,有没有人能够在 JSPDF 中编辑TextField()
的字体大小? I don't care if multi-line is true or false, I just need to be able to set the default font size of a TextField()
.我不在乎多行是真还是假,我只需要能够设置TextField()
的默认字体大小。
Here's my code, which comes from https://github.com/MrRio/jsPDF/blob/master/examples/js/acroforms.js :这是我的代码,来自https://github.com/MrRio/jsPDF/blob/master/examples/js/acroforms.js :
doc.text('TextField:', 10, 145);
var textField = new TextField();
textField.Rect = [50, 140, 30, 10];
textField.multiline = true;
textField.value = "The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse";//
textField.fieldName = "TestTextBox";
doc.addField(textField);
things I've tried:我尝试过的事情:
doc.setFontSize(10);
set this before adding the field of course.当然,在添加字段之前设置它。 no effect on textfield font size对文本字段字体大小没有影响textField.fontSize = 10
no effect on textfield font size textField.fontSize = 10
对文本字段字体大小没有影响textField.setFontSize(10)
throws error textField.setFontSize(10)
抛出错误I even tried downloading the library and altering it but couldn't get that to work.我什至尝试下载库并对其进行更改,但无法使其正常工作。
I also tried playing around on the testing site: http://raw.githack.com/MrRio/jsPDF/master/我还尝试在测试站点上玩耍: http://raw.githack.com/MrRio/jsPDF/master/
I found a similar question on GitHub but it was not asked well nor addressed: https://github.com/MrRio/jsPDF/issues/981我在 GitHub 上发现了一个类似的问题,但没有很好地询问也没有解决: https://github.com/MrRio/jsPDF/issues/981
I'm using the latest debug build: https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js我正在使用最新的调试版本: https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js
The default jsPDF behavior is to increase the font size to fill the TextField.默认的 jsPDF 行为是增加字体大小以填充 TextField。 You can prevent this by setting a maxFontSize like this:您可以通过像这样设置 maxFontSize 来防止这种情况:
doc.text('TextField:', 10, 145);
var textField = new TextField();
textField.Rect = [50, 140, 30, 10];
textField.multiline = true;
textField.value = "The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse The quick brown fox ate the lazy mouse";//
textField.fieldName = "TestTextBox";
//SET FONT SIZE
textField.maxFontSize = 9;
doc.addField(textField);
Hope this helps.希望这可以帮助。 The documentation is pretty sparse but can be found here: http://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormTextField.html文档很少,但可以在这里找到: http://raw.githack.com/MrRio/jsPDF/master/docs/module-AcroForm-AcroFormTextField.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.