
Now, we are going to insert some simple code to set the Text of the TX Text Control .NET Server 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 been already inserted. On this event, we are going to set the text and save the document. Add the following code to the created event:
[C#]
private void Button1_Click(object sender, System.EventArgs e)
{
InitializeComponent();
byte[] data;
serverTextControl1.Create();
serverTextControl1.Text = "TX Text Control .NET Server";
serverTextControl1.Save(out data, TXTextControl.BinaryStreamType.AdobePDF);
serverTextControl1.Dispose();
Response.BinaryWrite(data);
}
End Sub
[Visual Basic]
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
InitializeComponent
Dim data() As Byte
ServerTextControl1.Create()
ServerTextControl1.Text = "TX Text Control .NET Server"
ServerTextControl1.Save(data, TXTextControl.StreamType.AdobePDF)
ServerTextControl1.Dispose()
Response.BinaryWrite(data)
End Sub
The Create and the Dispose method must be called before and after using TX Text Control .NET Server to initialize and dispose the component. The Save method of TX Text Control .NET Server 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, the TX Text Control .NET Server creates the document and the returned PDF document is opened in the default external Adobe PDF viewer.