Search code examples
c#xamarin.formsstreamtruetype

Xamarin.Forms can't convert TTF file in stream


I'm working on Xamarin.Forms app with help of Syncfusion and want to add Cyrillic support in PDF drawing.I download ArialUnicodeMS.tff added the file in Shared Project in Resources folder and added Build Action Embedded Resource and also added [assembly: ExportFont("ArialUnicodeMS.ttf", Alias = "ArialUni")] in AssemblyInfo.cs. But Syncfusion Pdf Drawing want to access to the TTF file by Stream.

This is my code:

var assembly = IntrospectionExtensions.GetTypeInfo(typeof(EmbeddedFont)).Assembly;
Stream stream = assembly.GetManifestResourceStream("MyAppName.ArialUnicodeMS.ttf");
PdfFont font = new PdfTrueTypeFont(stream, 14);

But my string is always null. Where i'm getting wrong?


Solution

  • You could use the code below to get the stream from the Embeded resource.

       var assembly = Assembly.GetExecutingAssembly();
            var resourceName = "App28.Trashtalk.ttf";
            Stream stream = assembly.GetManifestResourceStream(resourceName);