Click or drag to resize

PdfIntegrationProviderProcessObjectDataRequest Method

Called when processing a request for object data initiated by the Client API which set the user mode to object insertion with a custom object key.

Namespace:  RadPdf.Integration
Assembly:  RadPdf (in RadPdf.dll) Version: 3.43.0.0 (3.43.0.0)
Syntax
public virtual void ProcessObjectDataRequest(
	PdfDataContext context
)

Parameters

context
Type: RadPdf.IntegrationPdfDataContext
An object (defined by PdfDataContext) that contains the request context.
Remarks

If this method is overridden in an inheriting class, do not call this base method.

This method is not triggered by changes made using a PdfDocumentEditor instance.

Examples
The following example overrides the default PdfIntegrationProvider to create a custom Integration Provider for use with ProcessObjectDataRequest in a web application.
C#
using System;
using System.Web;

using RadPdf.Data.Document.Objects.Shapes;
using RadPdf.Integration;

public class CustomPdfIntegrationProvider : PdfIntegrationProvider
{
        public override void ProcessObjectDataRequest(PdfDataContext context)
        {
            switch (context.Request.DataKey)
            {
                case "signature":
                    //Write a file to the response
                    //Alternatively, we could also use the .Write method to write data from almost any source (e.g. database, memory, generated on the file)
                    context.Response.WriteFile(@"C:\signature.gif");
                    break;
            }
        }
}
The following web.config file registers the above custom Integration Provider. This example assumes that CustomPdfIntegrationProvider is in the directory App_Code of your ASP.NET web application.
XML
<?xml version="1.0"?>
<configuration>
  <appSettings>
    <add key="RadPdfConnectionString" value="Server=.\SQLExpress;Database=RadPdf;Trusted_Connection=Yes;"/>
    <add key="RadPdfLicenseKey" value="DEMO"/>
    <add key="RadPdfIntegrationProvider" value="CustomPdfIntegrationProvider,App_Code"/>
  </appSettings>
  <system.web>
    <httpHandlers>
      <add path="RadPdf.axd" verb="GET,POST" type="RadPdf.Web.HttpHandler.PdfHttpHandler"/>
    </httpHandlers>
  </system.web>
  <!--
    The system.webServer element is for use with IIS 7 (and later) when Managed Pipeline Mode is set to "Integrated".
    It will be ignored in other versions of IIS.
    -->
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
      <add path="RadPdf.axd" verb="GET,POST" name="PdfHttpHandler" preCondition="integratedMode" type="RadPdf.Web.HttpHandler.PdfHttpHandler"/>
    </handlers>
  </system.webServer>
</configuration>
The following aspx and code behind files use the the client API to allow server side provided images to be added to a document.
C#
using System;

partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Get PDF as byte array from file (or database, browser upload, remote storage, etc)
            byte[] pdfData = System.IO.File.ReadAllBytes(@"C:\demo.pdf");

            //Load PDF byte array into RAD PDF
            this.PdfWebControl1.CreateDocument("Document Name", pdfData);
        }
    }
}
XML
<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="RadPdf" Namespace="RadPdf.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>
    <script type="text/javascript">
    function SetCustomImageTool()
    {
        //get id
        var id = "<%= PdfWebControl1.ClientID%>";

        //get api instance
        var api = new PdfWebControlApi(id);

        //set image mode
        api.setMode(api.Mode.InsertImageShape, "signature");
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <radPdf:PdfWebControl id="PdfWebControl1" runat="server" height="600px" width="100%" />
    </div>
    <div>
        <a href="#" onclick="SetCustomImageTool(); return false;">Set Custom Image Tool</a>
    </div>
    </form>
</body>
</html>
See Also