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;
}
}