HtmlArea.FontSelecting Event

Occurs when the Font is being selected to write the HtmlArea text. This can be used to change the font and related properties of the text.

public event HtmlAreaFontSelecting HtmlArea.FontSelecting;
Public Event HtmlArea.FontSelecting As HtmlAreaFontSelecting

Event Handler

HtmlAreaFontSelecting

Licensing Info

This event is a full DynamicPDF Core Suite feature. One of the following is required for non-evaluation usage:

Examples

This example shows simple HTML being displayed on the page.
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.LayoutEngine.LayoutElements
Imports ceTe.DynamicPDF.PageElements.Html

Public Class Example

    Public Shared Sub CreatePDF(inputHTMLPath As String, outputPath As String)
        
		' Create a Uri
		Dim url As Uri = New Uri(inputHTMLPath)
        
		' Create a PDF Document
		Dim document As Document = New Document()
        
		' create a html area
		Dim htmlArea As HtmlArea = New HtmlArea(url, 0, 0, 530, 580)
        
		' Adding Font Selecting Event
		AddHandler htmlArea.FontSelecting, AddressOf HtmlArea_FontSelecting
        
		' Create a new page
        Dim page As Page = New Page()
            
		' Add the html area to the page;
		page.Elements.Add(htmlArea)
        
		' Add the page to the document
		document.Pages.Add(page)
        
		//Save the PDF to disk
        document.Draw(outputPath)
    End Sub

    Private Shared Sub HtmlArea_FontSelecting(ByVal sender As Object, ByVal e As FontSelectingEventArgs)
        ' Update the Font and related properties as needed
		If e.FontFamily.Contains("Times") Then
            e.Font = Font.Helvetica
        End If
    End Sub
End Class
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;
using ceTe.DynamicPDF.PageElements.Html;

public class Example
{
    public static void CreatePDF(string inputHTMLPath, string outputPath)
	{
		// Create an Uri with the html file path
		Uri url = new Uri(inputHTMLPath);

		// Create Document object
		Document document = new Document();

		// create an html area
		HtmlArea htmlArea = new HtmlArea(url, 0, 0, 530, 580);

		// Adding Font Selecting Event
		htmlArea.FontSelecting += HtmlArea_FontSelecting;

		// Create a new page
		Page page = new Page();

		// Add the html area to the page;
		page.Elements.Add(htmlArea);

		// Add the page to the document
		document.Pages.Add(page);

		//Save the PDF to disk
		document.Draw(outputPath);
	}

	private static void HtmlArea_FontSelecting(object sender, FontSelectingEventArgs e)
	{
		// Update the Font and related properties as needed
		if (e.FontFamily.Contains("Times"))
		{
			e.Font = Font.Helvetica;
		}
	}
}

See Also

ceTe.DynamicPDF.PageElements.Html

In this topic