Skip to content Skip to sidebar Skip to footer

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? I don't care if multi-line is true or false, I just need to be able to set the default font size

Solution 1:

The default jsPDF behavior is to increase the font size to fill the TextField. You can prevent this by setting a maxFontSize like this:

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

Post a Comment for "How To Edit Font Size For Textfield() In Jspdf?"