We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Missing special characters in the generated PDF(?-?)

Hello!

I have an issue with the hungarian special characters : ‘ő’ and ‘ű’. They don’t displayed in the result pdf. But other special characters are OK, like : ú, ó, etc.

the code:

Aspose.Pdf.Generator.Text txt = new Aspose.Pdf.Generator.Text(“abcőűefg”);
txt.IsHtmlTagSupported = true;

Aspose.Pdf.Generator.Section section = new Aspose.Pdf.Generator.Section();
section.Paragraphs.Add(txt);

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
pdf.Sections.Add(section);

FileContentResult result = null;

using (MemoryStream ms = new MemoryStream())
{
pdf.Save(ms);
result = new FileContentResult(ms.ToArray(), “application/pdf;charset=UTF-8”)
{
FileDownloadName = fileName
};
}

the result in the pdf:
abc efg

So the ‘ő’ and ‘ű’ characters are missing.

I would be appreciate it, if you could give me some encoding options or something like that.

Thank you!
Daniel

Solution:


pdf.SetUnicode();

Problem solved :smiley:

Hi Daniel,


Thanks for contacting support.

We are glad to hear that your problem is resolved as SetUnicode(…) is used to render Unicode characters inside PDF document when using legacy Aspose.Pdf.Generator approach. However you may also consider using new Document Object Model (DOM) of Aspose.Pdf namespace as it produces correct output.

[C#]

Aspose.Pdf.Document pdfDocument = new Document();<o:p></o:p>

pdfDocument.Pages.Add();

Aspose.Pdf.Text.TextFragment fragment = new TextFragment("abcőűefg");

pdfDocument.Pages[1].Paragraphs.Add(fragment);

pdfDocument.Save("c:/pdftest/HungarianCharacters.pdf");