I am using the following code to add a textbox to my PDF file:
Dim stamper As PdfStamper = New PdfStamper(New PdfReader(sInputFile), File.Create(sOutputFile))
Dim iPageNumer As Integer = 1
Dim tf As TextField
tf = New TextField(stamper.Writer, New iTextSharp.text.Rectangle(33, 780, 30, 28), "SomeName")
Dim bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, False)
With tf
.Alignment = Element.ALIGN_CENTER And Element.ALIGN_MIDDLE
.BackgroundColor = GrayColor.GRAYBLACK
.BorderColor = Color.GREEN
.BorderStyle = PdfBorderDictionary.STYLE_SOLID
.DefaultText = "This is a new text field."
.Font = bf
.FontSize = 7
.MaxCharacterLength = 25
.Options = TextField.REQUIRED Or TextField.MULTILINE
.Text = "This is the assigned value."
End With
stamper.AddAnnotation(tf.GetTextField(), iPageNumer)
stamper.Close()
This creates a textbox which is almost as high as the document.
However, I expect the textbox to be 30, 28 only.
I guess Y = 780 is correct because iTextSharp starts at bottom left.
What am I not seeing here?
Thank you!
This is what it looks like:
Its width is 5 pixels only, and its height is 806 pixels.
question from:
https://stackoverflow.com/questions/65851383/why-is-my-itextsharp-pdf-textbox-so-large 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…