For console application code you can refer below code.
C#
class Program
{
static void Main(string[] args)
{
string folderPath = "D:\\PDFs\\";
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
using (FileStream stream = new FileStream(folderPath + "Test.pdf", FileMode.Create))
{
PdfPTable hedertable = new PdfPTable(1);
//BaseFont bf1 = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\ARIALUNI.TTF", BaseFont.IDENTITY_H, true);
BaseFont bf1 = BaseFont.CreateFont(AppDomain.CurrentDomain.BaseDirectory.Replace("bin\\Debug\\", "") + "\\fonts\\Dubai-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, true);
string cellTextm = "الخطة التشغيلية لمبادرة دراية لعام" + " 2020 " + "م";
Font fontheader = new Font(bf1, 20, Font.NORMAL);
PdfPCell mcell = new PdfPCell(new Phrase(16, cellTextm, fontheader))
{
HorizontalAlignment = Element.ALIGN_TOP,
VerticalAlignment = Element.ALIGN_TOP,
RunDirection = PdfWriter.RUN_DIRECTION_RTL,
Border = 0
};
hedertable.AddCell(mcell);
//Create PDF
Document pdfDoc = new Document(PageSize.A4.Rotate(), 10f, 10f, 10f, 10f);
PdfWriter.GetInstance(pdfDoc, stream);
pdfDoc.Open();
pdfDoc.Add(hedertable);
pdfDoc.Close();
}
}
}
VB.Net
Class Program
Private Shared Sub Main(ByVal args As String())
Dim folderPath As String = "D:\PDFs\"
If Not Directory.Exists(folderPath) Then
Directory.CreateDirectory(folderPath)
End If
Using stream As FileStream = New FileStream(folderPath & "Test.pdf", FileMode.Create)
Dim hedertable As PdfPTable = New PdfPTable(1)
Dim bf1 As BaseFont = BaseFont.CreateFont(AppDomain.CurrentDomain.BaseDirectory.Replace("bin\Debug\", "") & "\fonts\Dubai-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, True)
Dim cellTextm As String = "الخطة التشغيلية لمبادرة دراية لعام" & " 2020 " & "م"
Dim fontheader As Font = New Font(bf1, 20, Font.NORMAL)
Dim mcell As PdfPCell = New PdfPCell(New Phrase(16, cellTextm, fontheader)) With {
.HorizontalAlignment = Element.ALIGN_TOP,
.VerticalAlignment = Element.ALIGN_TOP,
.RunDirection = PdfWriter.RUN_DIRECTION_RTL,
.Border = 0
}
hedertable.AddCell(mcell)
Dim pdfDoc As Document = New Document(PageSize.A4.Rotate(), 10F, 10F, 10F, 10F)
PdfWriter.GetInstance(pdfDoc, stream)
pdfDoc.Open()
pdfDoc.Add(hedertable)
pdfDoc.Close()
End Using
End Sub
End Class