This example shows how to create a report that uses the custom font shipped with the application.
In this example, the DXFontRepository object instance loads a font from a file. The report constructor creates a new font and a XRControlStyle report style based on the newly created font. The new custom style is added to the XtraReport.StyleSheet collection.
Note
Although this example is a Web Forms application, the technique is valid for all DevExpress Reporting platforms.
Files to Review
- Global.asax.cs (VB: Global.asax.vb)
- Default.aspx (VB: Default.aspx)
- SampleReport.cs (VB: SampleReport.vb)
Documentation
More Examples
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
C#using DevExpress.Drawing;
using DevExpress.Utils.Serializing;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
namespace E5198 {
public class Global : System.Web.HttpApplication {
protected void Application_Start(object sender, EventArgs e) {
string fontFilePath = HttpContext.Current.Server.MapPath("~/Fonts/MissFajardose-Regular.ttf");
byte[] fontData = System.IO.File.ReadAllBytes(fontFilePath);
DXFontRepository.Instance.AddFont(fontData);
DevExpress.XtraReports.Web.ASPxWebDocumentViewer.StaticInitialize();
}
protected void Session_Start(object sender, EventArgs e) {
}
protected void Application_BeginRequest(object sender, EventArgs e) {
}
protected void Application_AuthenticateRequest(object sender, EventArgs e) {
}
protected void Application_Error(object sender, EventArgs e) {
}
protected void Session_End(object sender, EventArgs e) {
}
protected void Application_End(object sender, EventArgs e) {
}
}
}
ASPx<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="E5198.Default" %>
<%@ Register Assembly="DevExpress.XtraReports.v24.2.Web.WebForms, Version=24.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.XtraReports.Web" TagPrefix="dx" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxWebDocumentViewer ID="ASPxWebDocumentViewer1" runat="server" ReportSourceId="E5198.SampleReport">
</dx:ASPxWebDocumentViewer>
</div>
</form>
</body>
</html>
C#using DevExpress.Drawing;
using System.Drawing;
using System.Linq;
namespace E5198 {
public partial class SampleReport : DevExpress.XtraReports.UI.XtraReport {
public SampleReport() {
InitializeComponent();
customFontStyle.Font =
new DXFont("Miss Fajardose", 48F, DXFontStyle.Regular, DXGraphicsUnit.Point);
}
}
}