Declined
Last Updated: 23 Sep 2021 08:46 by ADMIN
Linus
Created on: 21 Sep 2021 06:41
Category: PdfProcessing
Type: Bug Report
0
HTML body to PDF with special characters "åäö"

Hi, 

 

I am trying to convert a HTML body to a PDF using HtmlFormatProvider and PdfFormatProvider. 

It works well when I try to create a pdf with "normal" characters, but when I use characters like "åäö" the characters is either missing or replaced with other character. 

I have found a similiar issue but that was due to the fact that the person was using .net core I am using .net framework. 

Am I missing something when I am converting it to a PDF or is there a limitation with special characters like "åäö". 

 


        private string CreateAndStorePdf(string htmlBody)
        {
            Telerik.Windows.Documents.Extensibility.JpegImageConverterBase jpegImageConverter = new Telerik.Documents.ImageUtils.JpegImageConverter();
            Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.JpegImageConverter = jpegImageConverter;

            var provider = new HtmlFormatProvider();
            var document = provider.Import(htmlBody);
            var exportProvider = new PdfFormatProvider();
            var fixedExportProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
            var fileName = "_original.pdf";

            try
            {
                using (var outputStream = new MemoryStream())
                {
                    exportProvider.Export(fixedExportProvider.ExportToFixedDocument(document), outputStream);
                    outputStream.Seek(0, SeekOrigin.Begin);
                    var pdfBytes = new BinaryReader(outputStream).ReadBytes((int)outputStream.Length);

                    return fileName;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "The pdf could not be created.");
                return null;
            }
        }

 

 

Attached Files:
2 comments
ADMIN
Dimitar
Posted on: 23 Sep 2021 08:46

Hi Linus,

After the provided information in the forum, it appears that this is a known issue. So I'm going to decline this one. 

Here is the issue in this case: WordsProcessing: HtmlFormatProvider: Automatically detect the encoding instead of relying on the one set in the HTML.

Do not hesitate to contact us if you have other questions.

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/.

Linus
Posted on: 22 Sep 2021 10:52

Created a question here intestad: 

https://www.telerik.com/forums/convert-html-to-pdf-with-special-characters