PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.
- Calculate the height of a paragraph in PDF
- Multipage TIFF to PDF
- Create PDF in C#
- Text formatting
- How to add page numbers to your PDF
- Append multiple PDF documents
- Add text field to PDF
- Convert XHTML to PDF
- Add footer with left and right aligned text on same line
- XhtmlParagraph and TrueType fonts
- What is the resulting fontsize in PDF for rich text used in a SimpleXhtmlShape
- Read and write meta data from PDF
- Merge PDF
- Stitch PDF documents
- Convert TXT to PDF
- Bulleted list from XML and XSL
- Use multiple licenses
- Generate PDF form from XML
Add text field to PDF
Code sample that shows how to add a text field to an existing PDF document.
Add text field to an existing PDF document
This code sample illustrates how you can add TextFields to your PDF. Do take note that you need to add a Widget to your document; in MVC terms the textfield is the model and the Widget is the view.
Document document = new Document();
Page page = new Page( PageSize.Letter );
document.Pages.Add( page );
TextField textField = new TextField( "text1" );
textField.Value = "Hello!";
document.Fields.Add( textField );
Widget widget = new Widget( 200, 400, 200, 50 );
widget.FontSize = 0; // auto-size
widget.TextColor = RgbColor.Red;
widget.BorderColor = RgbColor.Black;
widget.BorderStyle = BorderStyle.Solid;
widget.BorderWidth = 2;
textField.Widgets.Add( widget );
page.Widgets.Add( widget );
using ( FileStream file = new FileStream("addtextfield.pdf", FileMode.Create, FileAccess.Write))
{
document.Write( file );
}
Dim document As New Document()
Dim page As New Page(PageSize.Letter)
document.Pages.Add(page)
Dim textField As New TextField("text1")
textField.Value = "Hello!"
document.Fields.Add(textField)
Dim widget As New Widget(200, 400, 200, 50)
widget.FontSize = 0
' auto-size
widget.TextColor = RgbColor.Red
widget.BorderColor = RgbColor.Black
widget.BorderStyle = BorderStyle.Solid
widget.BorderWidth = 2
textField.Widgets.Add(widget)
page.Widgets.Add(widget)
Using file As New FileStream("addtextfield.pdf", FileMode.Create, FileAccess.Write)
document.Write(file)
End Using
Download TallPDF.NET 4.0
We will send you a download link
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download
We have sent an email with a download link.