Please give a brief summary of your issue:
I need to detect if all the text in the text annotation will be displayed or if it will be clipped
Please describe your issue and provide steps to reproduce it:
I have TextWidget or FreeText annotation with fixed dimensions. The text in the annotation can change and I need to inform the user that part of the text is not visible in the annotation field because it’s too long.
Is it possible to precisely calculate it, taking the word wrap funcationality of the free text annotation into the account?
Though, this creates a RubberStamp annotation. If you like, you can edit it to be a FreeText by post-processing this way. First, to get the Stamp annot after stamping see this post.
That will create the annotation with the size you want, and the appearance you want, however it is the wrong type of annotation. A RubberStamp one instead of a FreeText. So you can just take the size and appearance of the RubberStamp and use it to finish off a new FreeText annotation. This code shows how to swap them around.
// Create FreeText annotation as normal, applying the same colors, font and font size as the Stamper.
FreeText ft = FreeText.Create(doc, stamp_annot.GetBBox());
ft.SetContents(text_used_with_Stamper_StampText);
// ft.SetFont(...)
// ... etc.
ft.Put("AP", stamp_annot.FindObj("AP"));
stamp_annot.Erase("AP");
page.AnnotRemove(stamp_annot);
page.AnnotPushBaclk(ft);