Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Right to left languages (persian, arabic, ...) #144

Open
Gholamalih opened this issue Apr 17, 2021 · 4 comments
Open

Support Right to left languages (persian, arabic, ...) #144

Gholamalih opened this issue Apr 17, 2021 · 4 comments
Labels
suggestion Suggestion or feature request

Comments

@Gholamalih
Copy link

Gholamalih commented Apr 17, 2021

for example when we draw persian string "سلام" it draws "م ا ل س"

@ThomasHoevel ThomasHoevel added the suggestion Suggestion or feature request label Apr 19, 2021
@ThomasHoevel
Copy link
Member

Known implementation restriction, see FAQ.

@Gholamalih
Copy link
Author

why we didn't use .Net's Graphic class? this class can handle right to left languages.

@ThomasHoevel
Copy link
Member

Maybe .NET’s Graphics class can not handle PDF. Feel free to prove me wrong. Is there an easy way to use it for PDF generation?

@ibrhabash
Copy link

you can rivers string and pike the right glyph for character you can use AraibcPdfUnicodeGlyphsResharper to help

using PdfSharp.Drawing;
using PdfSharp.Pdf;
using AraibcPdfUnicodeGlyphsResharper;
namespace MigraDocArabic
{
internal class PrintArabicUsingPdfSharp
{
    public PrintArabicUsingPdfSharp(string path)
    {
        PdfDocument document = new PdfDocument();
        document.Info.Title = "Created with PDFsharp";
        System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
        // Create an empty page
        PdfPage page = document.AddPage();

        // Get an XGraphics object for drawing
        XGraphics gfx = XGraphics.FromPdfPage(page);

        // Create a font
        XFont font = new XFont("Arial", 20, XFontStyle.BoldItalic);
        var xArabicString = "كتابة اللغة  العربية شيئ جميل".ArabicWithFontGlyphsToPfd();
        // Draw the text
        gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height), XStringFormats.Center);
        gfx.DrawString(xArabicString, font, XBrushes.Black, new XRect(50, 50, page.Width, page.Height), XStringFormats.Center);

        // Save the document...
        document.Save(path);

    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Suggestion or feature request
Projects
None yet
Development

No branches or pull requests

3 participants