Hopding / pdf-lib

Create and modify PDF documents in any JavaScript environment
https://pdf-lib.js.org
MIT License
7.02k stars 676 forks source link

Text size shrinking and expanding in Text Fields as per text length. #1548

Open thehamzajunaid opened 1 year ago

thehamzajunaid commented 1 year ago

What were you trying to do?

I wanted a text field which can show my text using a predefined font size. If the the text field is small to show all my text then I was expecting to have a "keyboard down press button" functionality to scroll through the text. My text is multiline and sometimes single line.

How did you attempt to do it?

page.drawText('Some Title: ', { x: fieldX, y: 650, size: 12}); const textField = form.createTextField("favourite.stringValueFromBackend"); textField.enableMultiline(); if(stringValueFromBackend){ textField.setText(stringValueFromBackend) } textField.addToPage(page, { x: fieldX, y: 630, width: fieldWidth, height: 15 });

What actually happened?

image

You can see the squeezed text with a very small font size. Title and Output fields are also of the same height.

What did you expect to happen?

image

I was expecting something like this where I can scroll my text content using keyboard down press key.

How can we reproduce the issue?

The above code that I have provided is enough to execute it.

Version

^1.17.1

What environment are you running pdf-lib in?

Node

Checklist

Additional Notes

No response