Freetext Annotation Text padding

How do I put Freetext Annotation text padding?

PDF.js Express Version

Detailed description of issue
There is an issue where the top of the text is cut off.

Expected behaviour
I want the text to be padded at the top so that the text is not cut off.

Code snippet
newAnnot.Width = 100;
newAnnot.Height = 30;
newAnnot.X = 10;
newAnnot.Y = 10;
newAnnot.FontSize = ‘20pt’;
newAnnot.TextColor = new Annotations.Color(0, 0, 0);
newAnnot.setPadding(new Annotations.Rect(0, 0, 0, 0));
newAnnot.StrokeThickness = 0;
annotManager.addAnnotation(newAnnot, true);

1 Like


You can change the values in ‘setPadding’ to add padding to the top.

newAnnot.setPadding(new Annotations.Rect(0, 0, 0, 50));

You’ll have to increase the height of the annotation as well.

We have some small improvements coming to the freetext annotation in the next patch so this may help with the text getting cut off as well.