We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

how to draw a Arabic text on pdf page?

Thread ID:

Created:

Updated:

Platform:

Replies:

103904 Jun 7,2012 11:30 AM UTC Jun 22,2012 08:59 AM UTC WPF 3
loading
Tags: PDF
Steven Hongbin Zhou
Asked On June 7, 2012 11:30 AM UTC

Hi I am trying to use SyncfusionGraphics.PdfTextElement to draw a Arabic text(سیتوژنتیک_) on pdf page, but all of the chars become to question marks,so how to draw a Arabic text on pdf page? below is my code:

Syncfusion.Pdf.Graphics.PdfStringFormat format = new Syncfusion.Pdf.Graphics.PdfStringFormat();
format.Alignment = Syncfusion.Pdf.Graphics.PdfTextAlignment.Left;
SyncfusionGraphics.PdfTextElement text = new SyncfusionGraphics.PdfTextElement()
        {
            "سیتوژنتیک"
            Font = font,
            StringFormat = format,
            Brush = this.GetPdfBrush(textBlockInfo.FontColor)
        };
       
    text.Draw(page, position,
                 page.Size.Width - page.Section.PageSettings.Margins.Left - page.Section.PageSettings.Margins.Right, layoutFormat);


Geetha M [Syncfusion]
Replied On June 8, 2012 04:27 AM UTC

Hi Steven,

Thank you for your interest in Syncfusion products.

I am afraid that I was not able to reproduce the problem when drawing Arabic text with embedded font. I had placed the code snippet in the below:

PdfDocument document = new PdfDocument();
PdfPage page = document.Pages.Add();

PdfStringFormat format = new PdfStringFormat();
format.Alignment = PdfTextAlignment.Left;

PdfTextElement text = new PdfTextElement();
text.Text = "سیتوژنتیک";
text.Font = new PdfTrueTypeFont(new Font("Arial", 10f), true);
text.StringFormat = format;
text.Brush = PdfBrushes.Black;

text.Draw(page, PointF.Empty);

document.Save("Sample.pdf");
document.Close(true);

Could you please try this and let me know if you still see the problem?

Regards

Geetha

Steven Hongbin Zhou
Replied On June 21, 2012 04:32 AM UTC

Hi Geetha

I tried your source code, the Arabic text display. But when I use below test case, the chars "基因遗传学" was lost, do you know how to resolve this issue?

 PdfDocument document = new PdfDocument();
            PdfPage page = document.Pages.Add();

            PdfStringFormat format = new PdfStringFormat();
            format.Alignment = PdfTextAlignment.Left;

            PdfTextElement text = new PdfTextElement();
            text.Text = "559_XXXXXRegionsOfInterestسیتوژنتیک基因遗传学_.hg19.bed";
            text.Font = new PdfTrueTypeFont(new Font("Arial", 10f), true);
            text.StringFormat = format;
            text.Brush = PdfBrushes.Black;
            text.Draw(page, PointF.Empty);
            document.Save("Sample.pdf");
            document.Close(true);

The attachment file is my test restult.

Thanks
Steven


Sample_7e969cd3.zip

Geetha M [Syncfusion]
Replied On June 22, 2012 08:59 AM UTC

Hi Steven,

Thank you for the details.

It appears that Chinese characters cannot be displayed using "Arial" font in Adobe. To draw both Arabic and Chinese texts, please make use of "Arial Unicode MS" font or other equivalent font. Here is the code snippet.

text.Text = "559_XXXXXRegionsOfInterestسیتوژنتیک基因遗传学_.hg19.bed";
text.Font = new PdfTrueTypeFont(new Font("Arial Unicode MS", 10f), true);

Please try this and let me know if you have any questions.

Regards
Geetha

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;