Exporting HTML to PDF with greek characters in HTML

3 posts, 0 answers
  1. web
    web avatar
    6 posts
    Member since:
    Dec 2019

    Posted 02 Dec 2020 Link to this post

    Hi Everyone,

    i am trying to convert an HTML to PDF using RadFlowDocument. In HTML we have Greek Letters in the text and the export seems to ingore them and they are not printed in the final PDF.

     

    This is a sample of my code:

    <code>

    string html = "<p>Greek Characters</p><p>Ε</p>";

    var providerPdf = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
    var memoryStream = new MemoryStream();

     var providerHtml = new Telerik.Windows.Documents.Flow.FormatProviders.Html.HtmlFormatProvider();
    providerHtml.ExportSettings.ImagesExportMode = Telerik.Windows.Documents.Flow.FormatProviders.Html.ImagesExportMode.Embedded;
    providerHtml.ExportSettings.ImageExporting += (s, e) =>
    {
    e.Handled = false;
                        e.Title = "Test image";
                        e.ExportSize = true;
                        e.AlternativeText = "You will see this text if the image is not loaded";
                    };

                    RadFlowDocument document = providerHtml.Import(finalHtml);
                    providerPdf.Export(document, memoryStream);

                    using (Stream output = File.OpenWrite(@"C:\TempThanasis\sample.pdf"))
                    {
                        providerPdf.Export(document, output);
                    }

     

    </code>

     

    Thanks

  2. web
    web avatar
    6 posts
    Member since:
    Dec 2019

    Posted 02 Dec 2020 in reply to web Link to this post

    Here is the exported pdf in print screen which ingores greek characters.

     

  3. Dimitar
    Admin
    Dimitar avatar
    2983 posts

    Posted 03 Dec 2020 Link to this post

    Hi Chrysostomos,

    What is the type of your application, is it a Net Framework application or Net Core application? If you are using a Net Core app you may need to manually register a font that contains the gree characters. You can check the current font from the document properties (see attached).

    In addition, can you export the document to the docx format and see if the characters appear there? 

    I am looking forward to your reply.

    Regards,
    Dimitar
    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Back to Top