Hopding / pdf-lib

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

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

Open thehamzajunaid opened 9 months ago

thehamzajunaid commented 9 months 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