Class PdfLoadedDocument.PdfFontEventHandler
The EventHandler for Substituting a PDF font.
Inheritance
System.Object
PdfLoadedDocument.PdfFontEventHandler
Assembly: Syncfusion.Pdf.NET.dll
Syntax
public sealed class PdfFontEventHandler : MulticastDelegate
Examples
FileStream docStream = new FileStream(@"Input.pdf", FileMode.Open, FileAccess.Read);
PdfLoadedDocument doc = new PdfLoadedDocument(docStream);
PdfLoadedTextBoxField textBoxField = doc.Form.Fields[0] as PdfLoadedTextBoxField;
doc.Form.SetDefaultAppearance(false);
doc.SubstituteFont += Doc_SubstituteFont;
TextBoxField.Text = "syncfusion";
Save(doc, "Output.pdf");
Close the document
doc.Close(true);
Update Pdf Font event handler
void Doc_SubstituteFont(object sender, PdfFontEventArgs args)
{
string fontName = args.FontName
//Create the type face.
SKTypeface typeface = SKTypeface.FromFamilyName(fontName, SkiaSharp.SKFontStyleWeight.Light, SkiaSharp.SKFontStyleWidth.Normal, SkiaSharp.SKFontStyleSlant.Upright);
//Create stream assest using type face.
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 |
System.Object |
object |
|
System.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 |
System.Object |
sender |
|
PdfFontEventArgs |
args |
|
System.AsyncCallback |
callback |
|
System.Object |
object |
|
Returns
EndInvoke(IAsyncResult)
Declaration
public virtual void EndInvoke(IAsyncResult result)
Parameters
Type |
Name |
Description |
System.IAsyncResult |
result |
|
Invoke(Object, PdfFontEventArgs)
Declaration
public virtual void Invoke(object sender, PdfFontEventArgs args)
Parameters