unidoc / unipdf

Golang PDF library for creating and processing PDF files (pure go)
https://unidoc.io
Other
2.46k stars 250 forks source link

[FEATURE] Get number of lines in a textfield #521

Closed whizkid79 closed 8 months ago

whizkid79 commented 11 months ago

Is your feature request related to a problem? Please describe. I have a pdf with a multiline text field which is programmatically filled by unipdf. The text is wrapping around automatically. Is there a way to determine the amount of lines, which are filled by the text? Or at least the bounding box of the text?

Describe the solution you'd like I am open for anything. A getNumberOfLines on a Textfield would be great.

Describe alternatives you've considered I tried to get the informtion from the existing object model without luck.

sampila commented 11 months ago

Hi @whizkid79,

Could you share the PDF file and the results that you are expecting? For getting the bounding box of the text, you can use the https://github.com/unidoc/unipdf-examples/blob/master/extract/extract_text_bound.go

whizkid79 commented 11 months ago

Hi @sampila,

here are the PDF examples. form-lines-1.pdf form-lines-2.pdf form-lines-3.pdf I need to know the number of lines or something similar. so I would like to have a 1 for form-lines-1.pdf and so on. HTH.

sampila commented 10 months ago

Hi @whizkid79,

Upon looking at the document, looks like you want to get the number of lines inside form field. We will try to find workaround regarding this.

whizkid79 commented 10 months ago

Any news here @sampila?

3ace commented 9 months ago

@whizkid79 you could try this code to get a number of text in the text field, this should have worked using the pdf samples you provided above.

https://gist.github.com/3ace/91309575457dfea43f09aff6441afa37

3ace commented 8 months ago

@whizkid79 I hope the previous workaround is suitable for your need. I'm closing this issue now. Let us know if you have further concern on this.

Thank you