Delegate SvgConverter.PdfFontEventHandler
The event handler for substituting a PDF font when the required font is not embedded in the SVG document.
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
Methods
BeginInvoke(object, PdfFontEventArgs, AsyncCallback, object)
Declaration
public virtual IAsyncResult BeginInvoke(object sender, PdfFontEventArgs args, AsyncCallback callback, object @object)
Parameters
Returns
EndInvoke(IAsyncResult)
Declaration
public virtual void EndInvoke(IAsyncResult result)
Parameters
Invoke(object, PdfFontEventArgs)
Declaration
public virtual void Invoke(object sender, PdfFontEventArgs args)
Parameters