alexa
menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Delegate SvgConverter.PdfFontEventHandler

    The event handler for substituting a PDF font when the required font is not embedded in the SVG document.

    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.NET.dll
    Syntax
    public delegate void SvgConverter.PdfFontEventHandler(object sender, PdfFontEventArgs args)
    Parameters
    Type Name Description
    object sender

    The SvgConverter instance requesting the font.

    PdfFontEventArgs args

    Provides font information and allows a substitute font stream to be specified.

    Examples
    SvgConverter converter = new SvgConverter();
    PdfTemplate svg = converter.Convert(filePath);
    converter.SubstituteFont += Converter_SubstituteFont;
    PdfDocument document = new PdfDocument();
    document.PageSettings.Margins.All = 0;
    document.PageSettings.Size = new SizeF(svg.Width, svg.Height);
    PdfPage page = document.Pages.Add();
    page.Graphics.DrawPdfTemplate(svg, new PointF(0, 0), new SizeF(svg.Width, svg.Height));
    string output = Path.Combine("Output.pdf");
    document.Save(output);
    document.Close(true);
    void Converter_SubstituteFont(object sender, PdfFontEventArgs args)
    {
     string fontName = args.FontName
     SKTypeface typeface = SKTypeface.FromFamilyName(fontName, SkiaSharp.SKFontStyleWeight.Light, SkiaSharp.SKFontStyleWidth.Normal, SkiaSharp.SKFontStyleSlant.Upright);
     SKStreamAsset typeFaceStream = typeface.OpenStream();
     MemoryStream memoryStream = null;
    
    
     typeFaceStream
    
    
     typeFaceStream.Length
     0
    
    
     {
        //Create fontData from type face stream. 
        byte[] fontData = new byte[typeFaceStream.Length - 1];
        typeFaceStream.Read(fontData, typeFaceStream.Length);
        typeFaceStream.Dispose();
        //Create the new memory stream from font data. 
        memoryStream = new MemoryStream(fontData);
     }
     //set the font stream to the event args. 
     args.FontStream = memoryStream;
    }

    Constructors

    PdfFontEventHandler(object, IntPtr)

    Declaration
    public PdfFontEventHandler(object @object, IntPtr method)
    Parameters
    Type Name Description
    object object
    IntPtr method

    Methods

    BeginInvoke(object, PdfFontEventArgs, AsyncCallback, object)

    Declaration
    public virtual IAsyncResult BeginInvoke(object sender, PdfFontEventArgs args, AsyncCallback callback, object @object)
    Parameters
    Type Name Description
    object sender
    PdfFontEventArgs args
    AsyncCallback callback
    object object
    Returns
    Type
    IAsyncResult

    EndInvoke(IAsyncResult)

    Declaration
    public virtual void EndInvoke(IAsyncResult result)
    Parameters
    Type Name Description
    IAsyncResult result

    Invoke(object, PdfFontEventArgs)

    Declaration
    public virtual void Invoke(object sender, PdfFontEventArgs args)
    Parameters
    Type Name Description
    object sender
    PdfFontEventArgs args
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved