user3636426
user3636426

Reputation: 177

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)

Upvotes: 1

Views: 890

Answers (2)

user3086751
user3086751

Reputation: 205

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)

Upvotes: 2

You should get more than "????", but you have to enable Unicode. See this sample:
http://pdfsharp.net/wiki/Unicode-sample.ashx

But there is a show stopper: PDFsharp does not (yet) support LTR and Arabic glyphs.
I don't know what this means. Maybe it is enough to reverse the string and select initial, middle, and final glyphs in your code, maybe you cannot get correct Arabic at all.

Upvotes: 1

Related Questions