Today, I would like to take a look at creating your first ASP.NET application, using TX Text Control Server for ASP.NET (incl. Windows Forms). I am going to show you how - with just a few lines of code - you can generate a document and export it to an Adobe PDF document.

If you have already installed either the full retail version or the free thirty day evaluation version of TX Text Control, you can find the source code to this sample application in the following directories in the standard TX Text Control install directory:

  • Samples\ASP.NET\VB.NET\Simple
  • Samples\ASP.NET\CSharp\Simple

I suggest that you take a look at the source code as you go along.

Advantages of Server Side Applications

There are many advantages of creating server side applications over their client side counterparts. Consider the following:

  1. Templates and databases are centralized, thus all end users are working on the same basis and are up to date anytime and everywhere.
  2. Server side applications are accessible via a web browser interface, so that end users have access to the most important documents anywhere in the world.
  3. Documents generated by centralize templates have the same look and feel, thus reinforcing the branding message of an enterprise.
  4. Not every single document must be saved individually, but can be created on demand, thus saving valuable storage space.


First of all, before we can start, we need to ensure that you have Internet Information Server (IIS) installed on your development server or on your local machine. Both are valid development environments: Commonly developers develop and test on their local machines and move their finished applications to a production server at a later stage.

TX Text Control Server for ASP.NET (incl. Windows Forms) supports IIS, version 5 or higher, running on Windows 2000, Windows XP or Windows Server 2003.

Creating the Project

Assuming that you have already run the TX Text Control Server for ASP.NET (incl. Windows Forms) installation program, start Visual Studio .NET and create a new project. Select either Visual Basic .NET or C# .NET as a project type, and ASP.NET Web Application as a template.

Text Control

Then use the Tools / Add/Remove Toolbox Items... command to include the file

in the new project. In the Customize Toolbox dialog box, select the .NET Framework Components tab and then click the Browse button.

Navigate to the directory in to which TX Text Control .NET for Windows Forms has been installed (

c:\Program Files\The Imaging Source\TXTextControl\bin
, if you did not change the default setup path) and double click on the file

Back in the Customize Toolbox dialog, scroll down to verify that the ServerTextControl component has been added:

Text Control

After closing the dialog box, you will see an additional icon appear at the bottom of the Components Toolbox, representing TX Text Control Server for ASP.NET (incl. Windows Forms).

Text Control

Creating the Component

The next step is to create a server side TX Text Control .NET for Windows Forms on a web form. Click on the ServerTextControl icon and drag it on to the form. The icon will appear at the bottom of the web form as a generic component:

Text Control

By clicking on the ServerTextControl icon, you can specify some properties, such as PageSize or the default PageMargins at design-time in the Properties Window. Now, choose a normal Button control from the Components Toolbox and draw it on the web form. Your form should look like this:

Text Control

In the next step, we are going to insert some simple code to set the text of TX Text Control Server for ASP.NET (incl. Windows Forms) and to export the resulting document as an Adobe PDF file.

Double-click the button to switch to the code view. The view will be opened and the button click event has already been inserted. On this event, we are going to set the text and save the document. Add the following code to the created event:

' Visual Basic
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
        System.EventArgs Handles Button1.Click
    Dim data() As Byte
    ServerTextControl1.Text = "TX Text Control Server for ASP.NET (incl. Windows Forms)"
    ServerTextControl1.Save(data, TXTextControl.StreamType.AdobePDF)
End Sub
// C#
private void Button1_Click(object sender, System.EventArgs e)
    byte[] data;
    serverTextControl1.Text = "TX Text Control Server for ASP.NET (incl. Windows Forms)";
    serverTextControl1.Save(out data, TXTextControl.BinaryStreamType.AdobePDF);
End Sub

The Create and the Dispose method must be called before and after using TX Text Control Server for ASP.NET (incl. Windows Forms) to initialize and dispose the component. The Save method of TX Text Control Server for ASP.NET (incl. Windows Forms) is used to save the content to a byte array. This array is returned to the browser using the Response.BinaryWrite method.

Press F5 to compile and start the application. After clicking the button, TX Text Control Server for ASP.NET (incl. Windows Forms) creates the document and the returned PDF document is opened in the default external Adobe PDF viewer.