Click or drag to resize

PdfIntegrationProviderLiteStorageProvider Property

Gets or sets an object that specifies the storage provider used for Lite Documents with RAD PDF applications using this integration provider.

Namespace:  RadPdf.Integration
Assembly:  RadPdf (in RadPdf.dll) Version: 3.48.0.0 (3.48.0.0)
Syntax
public PdfLiteStorageProvider LiteStorageProvider { get; set; }

Property Value

Type: PdfLiteStorageProvider
Remarks

The PdfLiteStorageProvider is responsible for storing information associated with a given Lite Document session.

By default, RAD PDF uses the DefaultPdfLiteStorageProvider which uses the RAD PDF System Service and its storage.

Examples
The following example overrides the default PdfIntegrationProvider to create a custom Integration Provider for the web application. This custom provider stores data simply using the file system.
C#
using System;
using System.IO;
using System.Web;

using RadPdf.Integration;

public class CustomPdfIntegrationProvider : PdfIntegrationProvider
{
    public CustomPdfIntegrationProvider() : base()
    {
        this.LiteStorageProvider = new CustomPdfLiteStorageProvider(@"C:\RadPdfStorage\");
    }
}
C#
using System;
using System.IO;
using System.Web;

using RadPdf.Lite;

public class CustomPdfLiteStorageProvider : PdfLiteStorageProvider
{
    private readonly DirectoryInfo _dir;

    public CustomPdfLiteStorageProvider(string path) : base()
    {
        _dir = new DirectoryInfo(path);

        if (!_dir.Exists)
        {
            _dir.Create();
        }
    }

    private string GetPath(PdfLiteSession session, int subtype)
    {
        return Path.Combine(_dir.FullName, session.ID.ToString("N") + "-" + subtype.ToString() + ".dat");
    }

    public override void DeleteData(PdfLiteSession session)
    {
        FileInfo[] files = _dir.GetFiles(session.ID.ToString("N") + "*");

        foreach (FileInfo file in files)
        {
            lock (string.Intern(file.FullName))
            {
                file.Delete();
            }
        }
    }

    public override byte[] GetData(PdfLiteSession session, int subtype)
    {
        string path = GetPath(session, subtype);

        lock (string.Intern(path))
        {
            if (!File.Exists(path))
            {
                return null;
            }

            return File.ReadAllBytes(path);
        }
    }

    public override void SetData(PdfLiteSession session, int subtype, byte[] value)
    {
        string path = GetPath(session, subtype);

        lock (string.Intern(path))
        {
            File.WriteAllBytes(path, value);
        }
    }
}
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="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>
See Also