RAD PDF - PDFescape for ASP.NET
Features Demo Download Support Purchase PDFescape Contact Us

RAD PDF - Interactive Demonstrations

Basic Demo | Customized PDF Viewer | Integration | PDF Document Editor | PDF Form Filler
View Source
In this example, we use the DocumentEditor to fill out several PDF form fields before the document is displayed in RAD PDF. We also have added an arrow object, which can not be moved, styled, resized, or deleted. A form field object has also been added, which can not be styled, resized, or deleted, but can be moved & filled.

RAD PDF Sample Source Files

Default.aspx

<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="RadPdfLibrary" Namespace="RadPdfLibrary.Web.UI" TagPrefix="radPdf" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>RAD PDF Sample</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <radPdf:RadPdfWebControl id="RadPdfWebControl1" runat="server" height="600px" width="100%" />
    </div>
    </form>
</body>
</html>

Default.aspx.cs

using System;
using System.Drawing;
using RadPdfLibrary.Data.Document;
using RadPdfLibrary.Data.Document.Common;
using RadPdfLibrary.Data.Document.Objects;
using RadPdfLibrary.Data.Document.Objects.FormFields;
using RadPdfLibrary.Data.Document.Objects.Shapes;

partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) 
        {
            this.RadPdfWebControl1.CreateDocument("filename", System.IO.File.ReadAllBytes(@"C:\demo.pdf")); 
            
            //Create DocumentEditor object
            DocumentEditor DocumentEditor1 =
                this.RadPdfWebControl1.EditDocument();

            //Fill out PDF field using field names
            ((RadPdfTextField)
              DocumentEditor1.Fields.Find("First Name"))
              .Value = "John";
            ((RadPdfTextField)
              DocumentEditor1.Fields.Find("Last Name"))
              .Value = "Smith";
            ((RadPdfCheckField)
              DocumentEditor1.Fields.Find("Product Support"))
              .Checked = true;

            //Add arrow object
            RadPdfArrowShape a =
              (RadPdfArrowShape)
              DocumentEditor1.Pages[0].CreateObject(RadPdfObjectCreatable.ShapeArrow);
            a.LineColor = new RadPdfColor(Color.Blue);
            a.LineWidth = 2;
            a.SetLine(200, 220, 40, 160);
            a.Moveable = false;
            a.Resizable = false;
            a.Stylable = false;
            a.Deletable = false;

            //Add text form field object
            RadPdfTextField f =
              (RadPdfTextField)
              DocumentEditor1.Pages[0].CreateObject(RadPdfObjectCreatable.FormFieldText);
            f.Resizable = false;
            f.Stylable = false;
            f.Deletable = false;

            //Commit DocumentEditor changes
            DocumentEditor1.Save();
        }
    }
}

Default.aspx

<%@ Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="RadPdfLibrary" Namespace="RadPdfLibrary.Web.UI" TagPrefix="radPdf" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>RAD PDF Sample</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <radPdf:RadPdfWebControl id="RadPdfWebControl1" runat="server" height="600px" width="100%" />
    </div>
    </form>
</body>
</html>

Default.aspx.vb

Option Explicit On
Option Strict On

Imports System.Drawing
Imports RadPdfLibrary.Data.Document
Imports RadPdfLibrary.Data.Document.Common
Imports RadPdfLibrary.Data.Document.Objects
Imports RadPdfLibrary.Data.Document.Objects.FormFields
Imports RadPdfLibrary.Data.Document.Objects.Shapes

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then

            Me.RadPdfWebControl1.CreateDocument("filename", System.IO.File.ReadAllBytes("C:\demo.pdf"))

            'Create DocumentEditor object
            Dim DocumentEditor1 As DocumentEditor = _
                Me.RadPdfWebControl1.EditDocument()

            'Fill out PDF field using field names
            DirectCast( _
              DocumentEditor1.Fields.Find("First Name"), _
              RadPdfTextField _
              ).Value = "John"
            DirectCast( _
              DocumentEditor1.Fields.Find("Last Name"), _
              RadPdfTextField _
              ).Value = "Smith"
            DirectCast( _
              DocumentEditor1.Fields.Find("Product Support"), _
              RadPdfCheckField _
              ).Checked = True

            'Add arrow object
            Dim a As RadPdfArrowShape = _
              DirectCast( _
              DocumentEditor1.Pages(0).CreateObject(RadPdfObjectCreatable.ShapeArrow), _
              RadPdfArrowShape)
            a.LineColor = New RadPdfColor(Color.Blue)
            a.LineWidth = 2
            a.SetLine(200, 220, 40, 160)
            a.Moveable = False
            a.Resizable = False
            a.Stylable = False
            a.Deletable = False

            'Add text form field object
            Dim f As RadPdfTextField = _
              DirectCast( _
              DocumentEditor1.Pages(0).CreateObject(RadPdfObjectCreatable.FormFieldText), _
              RadPdfTextField)
            f.Resizable = False
            f.Stylable = False
            f.Deletable = False

            'Commit DocumentEditor changes
            DocumentEditor1.Save()

        End If
    End Sub
End Class
Terms of Use | Privacy
RAD PDF & PDFescape are CTdeveloping, LLC products - ©2007-2009 CTdeveloping, LLC