ByteScout PDF SDK - C# - Add TextField to PDF form - ByteScout

ByteScout PDF SDK – C# – Add TextField to PDF form

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF SDK – C# – Add TextField to PDF form

How to add textfield to PDF form in C# with ByteScout PDF SDK

How to add textfield to PDF form in C#

This sample source code below will demonstrate you how to add textfield to PDF form in C#. ByteScout PDF SDK is the SDK for pdf documents generation, modification and updates. Can also generate and fill PDF forms. Provides support for text (fonts, style, size, font family), layers, pdf form fields, vector and raster drawings. It can add textfield to PDF form in C#.

C# code samples for C# developers help to speed up coding of your application when using ByteScout PDF SDK. In order to implement the functionality, you should copy and paste this code for C# below into your code editor with your app, compile and run your application. Code testing will allow the function to be tested and work properly with your data.

You can download free trial version of ByteScout PDF SDK from our website to see and try many others source code samples for C#.

Try ByteScout PDF SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

Program.cs
      
using System.Diagnostics; using Bytescout.PDF; namespace TextFields { /// <summary> /// This example demonstrates how text fields and theirs variations. /// </summary> class Program { static void Main() { // Create new document Document pdfDocument = new Document(); pdfDocument.RegistrationName = "demo"; pdfDocument.RegistrationKey = "demo"; // Add page Page page = new Page(PaperFormat.A4); pdfDocument.Pages.Add(page); // Add simple text field with default properties EditBox edit1 = new EditBox(20, 20, 120, 25, "editBox1"); edit1.Text = "One two three"; page.Annotations.Add(edit1); // Add password box EditBox edit2 = new EditBox(20, 50, 120, 25, "editBox2"); edit2.Text = "password"; edit2.Password = true; page.Annotations.Add(edit2); // Add multiline text field EditBox edit3 = new EditBox(20, 80, 120, 50, "editBox3"); edit3.Multiline = true; edit3.Text = "The quick brown fox jumps over, the lazy dog."; page.Annotations.Add(edit3); // Demonstrate various decoration properties EditBox edit4 = new EditBox(20, 135, 120, 30, "editBox4"); edit4.Text = "Decorated text field"; edit4.TextAlign = TextAlign.Right; edit4.BackgroundColor = new ColorRGB(255, 240, 240); edit4.BorderWidth = 2; edit4.BorderStyle = BorderStyle.Dashed; edit4.BorderColor = new ColorRGB(128, 0, 0); edit4.FontColor = new ColorRGB(128, 0, 0); edit4.Font.Size = 9; page.Annotations.Add(edit4); // Save document to file pdfDocument.Save("result.pdf"); // Cleanup pdfDocument.Dispose(); // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } } }

Try ByteScout PDF SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit ByteScout PDF SDK Home Page

Explore ByteScout PDF SDK Documentation

Get ByteScout PDF SDK Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Tutorials:

prev
next