Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF Form field too small for content #212

Open
whizkid79 opened this issue Jan 26, 2023 · 3 comments
Open

PDF Form field too small for content #212

whizkid79 opened this issue Jan 26, 2023 · 3 comments

Comments

@whizkid79
Copy link

Hi,
We have an issue at the moment where we have a pdf template with form fields we use to customize the pdf with our data and print it. The results are great.
But sometimes the text we want to put in, is too much for the size of the form field and gets cut off. We tried to increate the size of the field and make it multiline, which works for the longer text, but fails for shorter text because we cannot set it to be aligned to the bottom and that makes the shorter text float in mid air, not where it's supposed to. I added some screenshots for clarification.

Is there a good way to deal with this (programmatically)?

good case

bad case

Thanks,
Peter

@sampila
Copy link
Contributor

sampila commented Jan 26, 2023

Hi @whizkid79,

Could you share a runnable code snippet and pdf form file for this?

Have you tried to do something like

if len(firstName) > 30 {
  // do set the fields for first name to multiline
}

Like checking the field value and if exceeds maximum chars, set the field to multiline.

@whizkid79
Copy link
Author

Hi @sampila,
sorry for the late reply.
I haven't tried to check the string length. The issue is that 30x i is smaller than 30x X, so exact numbers won't work in all cases.
Is there a way to detect the overflow?
Or simply set the style of the formfield to vertical align on bottom?
All fields get flattened, so it might also be done in the flattening operation later.

Thanks, Peter

@whizkid79
Copy link
Author

Hi @sampila,
another idea: is it possible to get the bounding box of a text element? I could do a test with the same font on a separate document and measure the used space for it, then check the width of the form field and adjust accordingly.
Do you have any information on this approach?
Thanks,
Peter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants