Example E5198
Visible to All Users

Reporting for Web Forms - How to Use a Custom Font Distributed With the Application

This example shows how to create a report that uses the custom font shipped with the application.

Report with Custom Fonts

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

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

E5198/Global.asax.cs(vb)
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) { } } }
E5198/Default.aspx
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>
E5198/SampleReport.cs(vb)
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); } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.