WebFonts and WebIcons, Issues with Azure PDF

CSS includes Web Fonts, allowing you to specify font files to be downloaded along with your website as it is accessed. Here is a walkthrough on how to use WebFonts and Icons in your ASP.NET pages and Azure PDF projects.


Step 1

1. Install IronPDF Library

To work with this tutorial and the CSS WebFonts in a C# project, first we'll download the free for development IronPDF library. You can get it direct download or by accessing the NuGet package manager.


 PM > Install-Package IronPdf

How to Tutorial

2. Use WebFonts and Icons

WebFonts allow you to identify fonts for download with your website. This means that any supporting browser can have the exact fonts you specify available to it.

Icon fonts are fonts that are made up of symbols and glyphs and not letters or numbers.

IronPDF supports WebFonts (such as Google Fonts and the Adobe web font API) and Icon fonts such as those applied by Bootstrap and FontAwesome.

Learn more about working with PDF and SVG WebFonts.

Here is a small example on how to make use of a WebFont named Lobster in your ASP.NET pages and IronPDF.

/**
WebFonts in ASPNET Page
anchor-use-webfonts-and-icons
**/
private static void Main(string[] args)

{

string desktoppath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

var outfile = Path.Combine(desktoppath, "font-test.pdf");

ChromePdfRenderer myChromePdfRenderer = new IronPdf.ChromePdfRenderer();

var html = @"<link href=""https://fonts.googleapis.com/css?family=Lobster""

rel=""stylesheet""><p style=""font-family: 'Lobster', serif; font-size:30px;"" > Hello Google

Fonts</p>";

using PdfDocument doc = myChromePdfRenderer.RenderHtmlAsPdf(html);

doc.SaveAs(outfile);

Process.Start(outfile);

}
/**
WebFonts in ASPNET Page
anchor-use-webfonts-and-icons
**/
private static void Main(string[] args)

{

string desktoppath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

var outfile = Path.Combine(desktoppath, "font-test.pdf");

ChromePdfRenderer myChromePdfRenderer = new IronPdf.ChromePdfRenderer();

var html = @"<link href=""https://fonts.googleapis.com/css?family=Lobster""

rel=""stylesheet""><p style=""font-family: 'Lobster', serif; font-size:30px;"" > Hello Google

Fonts</p>";

using PdfDocument doc = myChromePdfRenderer.RenderHtmlAsPdf(html);

doc.SaveAs(outfile);

Process.Start(outfile);

}
'''
'''WebFonts in ASPNET Page
'''anchor-use-webfonts-and-icons
'''*
Public Shared Sub Main(ByVal args() As String)


Dim desktoppath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)

Dim outfile = Path.Combine(desktoppath, "font-test.pdf")

Dim myChromePdfRenderer As ChromePdfRenderer = New IronPdf.ChromePdfRenderer()

Dim html = "<link href=""https://fonts.googleapis.com/css?family=Lobster""

rel=""stylesheet""><p style=""font-family: 'Lobster', serif; font-size:30px;"" > Hello Google

Fonts</p>"

Using doc As PdfDocument = myChromePdfRenderer.RenderHtmlAsPdf(html)
	
	doc.SaveAs(outfile)
	
	Process.Start(outfile)
	
End Using
End Sub
VB   C#

3. Limitations on Azure PDF

The Azure hosting platform does not support servers loading SVG fonts in their cheaper shared webapp tiers. Azure's VPS and Web Role are not sandboxed in the same way and will support web font rendering.