Search code examples
vb.netimagepdfpdfsharp

draw x image text in arabic


I am using the code blow to draw text on a image which i will be adding to PDF which is working fine when i am adding English text. I would like to know how i can do this and add Arabic text. when i step through the code i can clearly see that the sting 'txtModule' is holding the text in Arabic. currenlt it is changeing the text to ????

Dim page As PdfPage = document.AddPage
        page.Orientation = PageOrientation.Landscape
        Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
        Dim XImage As XImage = XImage.FromFile("C:\Projects\CISIPR\currentPr\images\Certificate\prCertificate.jpg")
        gfx.DrawImage(XImage, 20, 20, 800, 564)

        Dim fontModule As New XFont("arial", 20, XFontStyle.Bold)



        ' Draw the Module text box

        gfx.DrawString(txtModule, fontModule, New PdfSharp.Drawing.XSolidBrush(PdfSharp.Drawing.XColor.FromArgb(103, 154, 165)), _
        New XRect(0, 10, page.Width.Point, page.Height.Point), XStringFormats.Center)

Solution

  • this code here will work in converting the font so;

    Dim options = New XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always)
    Dim fontModule As New XFont("arial", 20, XFontStyle.Bold, options)