Reputation: 117
i'm trying to create pdf using mix from Arabic and English but is not working clearly.
Dim Doc1 As Object = New Document()
Dim Path As String
Dim fontpath As String = "C:\Windows\Fonts"
Dim customfont As BaseFont = BaseFont.CreateFont(fontpath & "/Arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)
Dim Myfont As Font = New Font(customfont, 12)
Path = "C:\Users\LENOVO\Desktop\docs"
PdfWriter.GetInstance(Doc1, New FileStream(Path + "\Doc1.pdf", FileMode.Create))
Doc1.Open()
Doc1.Add(New Paragraph(" ملف جديد", Myfont))
Doc1.Close()
Upvotes: 2
Views: 336
Reputation: 95918
As Paulo already commented,
It will only work inside
ColumnText
orPdfPTable
.
Furthermore, you will have to activate support for bidirectional type setting by selecting the primary run direction.
You asked for a simple example:
Dim Doc1 As Object = New Document()
Dim Path As String
Dim fontpath As String = "C:\Windows\Fonts"
Dim customfont As BaseFont = BaseFont.CreateFont(fontpath & "/Arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)
Dim Myfont As Font = New Font(customfont, 12)
Path = "C:\Temp\test-results\content"
PdfWriter.GetInstance(Doc1, New FileStream(Path + "\WriteArabicLikeRyhana-Improved.pdf", FileMode.Create))
Doc1.Open()
Dim table As PdfPTable = New PdfPTable(1)
table.WidthPercentage = 100
Dim cell As PdfPCell = New PdfPCell()
cell.Border = PdfPCell.NO_BORDER
cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL
cell.AddElement(New Paragraph(" ملف جديد", Myfont))
table.AddCell(cell)
Doc1.add(table)
Doc1.Close()
The result:
Upvotes: 1