android – How to add Arabic font to Itext7 Xamarin form


I used the code below to add Arabic font to itext7 and it worked but when my pdf file is created, the Arabic words appear in separate letters and RIGHT_TO_LEFT not affect please support.

 public PdfFont GetFont(string filename, string fontName)
        {
            var assembly = typeof(ResultVehicleCheckList).GetTypeInfo().Assembly;
            var fontStream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.Assets.Fonts.{filename}");
     
            byte[] fontBytes;

            using (var memoryStream = new MemoryStream())
            {
                fontStream.CopyTo(memoryStream);
                fontBytes = memoryStream.ToArray();
            }

            return PdfFontFactory.CreateFont(fontBytes, PdfEncodings.IDENTITY_H, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED, true);
        }


         // Initialize fone
         PdfFont   font = GetFont("arial.ttf", "arial");

          // Initialize table
 Table table1 = new Table(5, true);
            table1.SetBaseDirection(BaseDirection.RIGHT_TO_LEFT);
            table1.SetWidth(MillimetersToPoints(185));
            table1.SetWidth(new UnitValue(UnitValue.PERCENT, 100));

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img