question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextField fontsize changes after editing content

See original GitHub issue

Feature requests, bug reports etc. are very welcome as issues. But questions are directed to stackoverflow with the tag jspdf.

If you are facing issues with utf-8 characters, please refer to #2677.

Note that bug reports should follow these guidelines:

  1. A bug should be reported as an mcve
  2. Make sure code is properly indented and formatted (Use ``` around code blocks)
  3. You can run example here http://raw.githack.com/MrRio/jsPDF/master/ for AcroForms and download pdf and check the font size on chrome browser Initial font size for input value is ok when we chnge text it appear larger
/* global jsPDF */
var doc = new jsPDF();
var {
  TextField,
  Appearance
} = jsPDF.AcroForm;

doc.setFontSize(12);

doc.text("TextField:", 10, 145);
var textField = new TextField();
textField.Rect = [50, 140, 30, 10];
textField.multiline = false;
textField.value ="Test value"; //
textField.fieldName = "TestTextBox";
doc.addField(textField);

  1. Please check ath attached Pdf and open it in chrome browser it show larger text inside input fields. AcroForms (2).pdf

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
bigmc10commented, Aug 30, 2022

I have this issue as well. Not only does font size change, but the font itself changes. I forked markandan’s codepen. I set the font and added starting text. On opening the pdf, it correctly uses Times font but not the 20 font size. When you click the text field, the font changes from Times to something else (sans serif), and it gets bigger (maybe the correct 20 font size).

Setting multiline = true altered the behavior. The font size gets smaller or stays the same when selected. But the font still definitely changes!

Once a field is edited by the user, it’s font and font size properties are stable (but they are NOT the font and font size set in the text field’s properties!). (EDIT: this is not exactly true. It looks like jsPDF is setting the fontSize to “auto” somehow. As a field’s content grows, the font size shrinks in an effort to fit it. I know this is not the way a pdf has to operate. Is there any way to create truly fixed font size using jsPDF?)

https://codepen.io/wwp5550/pen/zYWgBbE

1reaction
ymc-thzicommented, Jul 13, 2021

Have exactly the same issue. Found out as a quick fix workaround you can set formField.multiline = true; Then it does not change the fontSize while and after editing 🤷🏻‍♂️

Read more comments on GitHub >

github_iconTop Results From Across the Web

TextField fontsize changes after editing content #3071 - GitHub
Once a field is edited by the user, it's font and font size properties are stable (but they are NOT the font and...
Read more >
Cannot change font size of text field in material ui
Here's what I had to do to change the size of the text both before (label) and after (input text) the user interacts...
Read more >
Change the default font for adding text and fallback font for ...
Go to Edit > Preferences > Content Editing > Font Options. Select an appropriate font in the Fallback font for editing drop-down list....
Read more >
Text in Compose - Jetpack - Android Developers
You may want to adjust lineHeight using the text unit “em” (relative font size) instead of “sp” (scaled pixels) for improved precision. More...
Read more >
Using the rich text editor - Relativity Documentation
Set the long text field with the Display Type: Inline Rich Text. On the layout builder, make the long text field two column....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found