PdfIntegrationProviderProcessObjectDataRequest Method |
Namespace: RadPdf.Integration
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.
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; } } }
<?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>
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); } } }
<%@ 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>