PdfLiteSessionProvider Class |
Namespace: RadPdf.Lite
The PdfLiteSessionProvider type exposes the following members.
Name | Description | |
---|---|---|
![]() | PdfLiteSessionProvider |
Creates a new instance of the PdfLiteSessionProvider class.
|
Name | Description | |
---|---|---|
![]() | AddSession |
Adds a new PdfLiteSession to the provider.
|
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GenerateKey |
Gets a string which contains a randomly generated key using RNGCryptoServiceProvider.
|
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetSession |
Gets a PdfLiteSession from the provider associated with a given key.
|
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
using System; using System.Web; using RadPdf.Integration; public class CustomPdfIntegrationProvider : PdfIntegrationProvider { public CustomPdfIntegrationProvider() : base() { this.LiteSessionProvider = new CustomPdfLiteSessionProvider(); } }
using System; using System.Collections.Concurrent; using System.Web; using RadPdf.Lite; public class CustomPdfLiteSessionProvider : PdfLiteSessionProvider { // This example uses an in memory dictionary, which won't have // persistent storage, but a database or other key /value store // can easily be substituted. private readonly ConcurrentDictionary<string, byte[]> _dict; public CustomPdfLiteSessionProvider() : base() { _dict = new ConcurrentDictionary<string, byte[]>(); } public override string AddSession(PdfLiteSession session) { string key = GenerateKey(); _dict[key] = session.Serialize(); return key; } public override PdfLiteSession GetSession(string key) { byte[] data = _dict[key]; if (null == data) { return null; } return PdfLiteSession.Deserialize(data); } }
using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using RadPdf; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddSession(); // Setup WebApplication var app = builder.Build(); app.UseStaticFiles(); app.UseRouting(); app.UseSession(); app.UseAuthorization(); // Or however you normally process page requests app.MapRazorPages(); // Create middleware settings RadPdfCoreMiddlewareSettings settings = new RadPdfCoreMiddlewareSettings() { // Add SQL Server Connection String, if not using Lite Documents // Sample connection string below connects to a SQL Server Express instance on localhost // TrustServerCertificate=True is set to avoid a trust exception (e.g. "The certificate chain was issued by an authority that is not trusted.") // ConnectionString = @"Server=.\SQLExpress;Database=RadPdf;Trusted_Connection=Yes;TrustServerCertificate=True;", // Add License Key LicenseKey = "DEMO", // Attach the Integration Provider IntegrationProvider = new CustomPdfIntegrationProvider() // To run RAD PDF without the System Service, add UseService = false // If using Lite Documents without the System Service, a LiteStorageProvider must also be implemented //UseService = false }; // Add RAD PDF's middleware to app app.UseRadPdf(settings); app.Run();