Default.aspx
<%@ 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>
</head>
<body>
<form id="form1" runat="server">
<div>
<radPdf:PdfWebControl id="PdfWebControl1" runat="server" height="600px" width="100%" />
</div>
</form>
</body>
</html>
Default.aspx.cs
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:\unicode.pdf");
//Load PDF byte array into RAD PDF
this.PdfWebControl1.CreateDocument("Document Name", pdfData);
}
}
}
web.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="RadPdfConnectionString" value="Server=.\SQLExpress;Database=RadPdf;Trusted_Connection=Yes;"/>
<add key="RadPdfIntegrationProvider" value="UnicodePdfIntegrationProvider,App_Code"/>
<add key="RadPdfLicenseKey" value="DEMO"/>
</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>
App_Code\UnicodePdfIntegrationProvider.cs
using System;
using RadPdf.Integration;
public class UnicodePdfIntegrationProvider : PdfIntegrationProvider
{
public UnicodePdfIntegrationProvider()
: base()
{
// Enable Uniscribe to support complex text layouts and scripts, like those needed in Arabic or Thai
this.AdvancedSettings.UseUniscribe = true;
this.FontResources.Clear();
// Re-add Arial, which will automatically use Arial Unicode MS if installed and necessary
this.FontResources.Add(PdfFontResource.ArialFontResource);
// Add Unicode compatible font for server side (must be installed on server)
// This example uses Microsoft JhengHei (for Traditional Chinese), MS PGothic (for Japanese), and Malgun Gothic (for Korean) which are pre-installed on most versions of Windows
// For web clients not using Windows Vista or newer, we fall back to Google's Noto Sans font, then the default sans-serif font
// Noto fonts are open source fonts provided by Google (https://www.google.com/get/noto/) and published under the SIL Open Font License, Version 1.1
this.FontResources.Add(new PdfFontResource("MS PGothic", "\"MS PGothic\", \"MS Pゴシック\", \"Noto Sans JP\", sans-serif", "MS PGothic"));
this.FontResources.Add(new PdfFontResource("Malgun Gothic", "\"Malgun Gothic\", \"Noto Sans KR\", sans-serif", "Malgun Gothic"));
this.FontResources.Add(new PdfFontResource("Microsoft JhengHei", "\"Microsoft JhengHei\", \"Noto Sans TC\", sans-serif", "Microsoft JhengHei"));
}
public override void OnDocumentInit(DocumentInitEventArgs e)
{
base.OnDocumentInit(e);
// Add web font for client side fall back if CJK fonts aren't installed
// (fonts.bunny.net is a more privacy conscious option vs. fonts.googleapis.com)
e.ExternalStyle = "https://fonts.bunny.net/css?family=Noto+Sans+JP&family=Noto+Sans+KR&family=Noto+Sans+TC";
// Or to use Google Fonts:
// e.ExternalStyle = "https://fonts.googleapis.com/css?family=Noto+Sans+JP&family=Noto+Sans+KR&family=Noto+Sans+TC";
}
}
Default.aspx
<%@ Page Language="VB" CodeFile="Default.aspx.vb" 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>
</head>
<body>
<form id="form1" runat="server">
<div>
<radPdf:PdfWebControl id="PdfWebControl1" runat="server" height="600px" width="100%" />
</div>
</form>
</body>
</html>
Default.aspx.vb
Option Explicit On
Option Strict On
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
'Get PDF as byte array from file (or database, browser upload, remote storage, etc)
Dim pdfData As Byte() = System.IO.File.ReadAllBytes("C:\unicode.pdf")
'Load PDF byte array into RAD PDF
Me.PdfWebControl1.CreateDocument("Document Name", pdfData)
End If
End Sub
End Class
web.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="RadPdfConnectionString" value="Server=.\SQLExpress;Database=RadPdf;Trusted_Connection=Yes;"/>
<add key="RadPdfIntegrationProvider" value="UnicodePdfIntegrationProvider,App_Code"/>
<add key="RadPdfLicenseKey" value="DEMO"/>
</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>
App_Code\UnicodePdfIntegrationProvider.vb
Imports System
Imports RadPdf.Integration
Public Class UnicodePdfIntegrationProvider
Inherits PdfIntegrationProvider
Public Sub New()
MyBase.New()
' Enable Uniscribe to support complex text layouts and scripts, like those needed in Arabic or Thai
Me.AdvancedSettings.UseUniscribe = True
Me.FontResources.Clear()
' Re-add Arial, which will automatically use Arial Unicode MS if installed and necessary
Me.FontResources.Add(PdfFontResource.ArialFontResource)
' Add Unicode compatible font for server side (must be installed on server)
' This example uses Microsoft JhengHei (for Traditional Chinese), MS PGothic (for Japanese), and Malgun Gothic (for Korean) which are pre-installed on most versions of Windows
' For web clients not using Windows Vista or newer, we fall back to Google's Noto Sans font, then the default sans-serif font
' Noto fonts are open source fonts provided by Google (https://www.google.com/get/noto/) and published under the SIL Open Font License, Version 1.1
Me.FontResources.Add(New PdfFontResource("MS PGothic", "\"MS PGothic\", \"MS Pゴシック\", \"Noto Sans JP\", sans-serif", "MS PGothic"))
Me.FontResources.Add(New PdfFontResource("Malgun Gothic", "\"Malgun Gothic\", \"Noto Sans KR\", sans-serif", "Malgun Gothic"))
Me.FontResources.Add(New PdfFontResource("Microsoft JhengHei", "\"Microsoft JhengHei\", \"Noto Sans TC\", sans-serif", "Microsoft JhengHei"))
End Sub
Public Overrides Sub OnDocumentInit(ByVal e As DocumentInitEventArgs)
MyBase.OnObjectDataAdding(e)
' Add web font for client side fall back if CJK fonts aren't installed
' (fonts.bunny.net is a more privacy conscious option vs. fonts.googleapis.com)
e.ExternalStyle = "https://fonts.bunny.net/css?family=Noto+Sans+JP&family=Noto+Sans+KR&family=Noto+Sans+TC"
' Or to use Google Fonts:
' e.ExternalStyle = "https://fonts.googleapis.com/css?family=Noto+Sans+JP&family=Noto+Sans+KR&family=Noto+Sans+TC"
End Sub
End Class