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

Free Support Forum - aspose.com

UTF-8/ANSI encoded text file Conversion to Pdf

Hello there,

We are trying to convert text files to pdf using Aspose Pdf, we followed the code sample below and setting Aspose.Pdf.Generator.Pdf.SetUnicode().

This however fails to render ASCII characters encoded in ANSII format.

Can you advise how do we go about resolving this?


Thanks for using our API's.

I have tested the scenario using DOM approach of Aspose.Pdf namespace and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFNEWNET-40854 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.


// Read the source text file

TextReader tr = new StreamReader(myDir + "ASCII_Test.txt");

// Instantiate a Document object by calling its empty constructor

Document doc = new Document();

// Add a new page in Pages collection of Document

Page page = doc.Pages.Add();

// Create an instance of TextFragmet and pass the text from reader object to its constructor as argument

TextFragment text = new TextFragment(tr.ReadToEnd());

//text.TextState.Font = FontRepository.FindFont("Arial Unicode MS");

text.TextState.Font = FontRepository.FindFont("Arial Unicode MS");

// Add a new text paragraph in paragraphs collection and pass the TextFragment object


// Save resultant PDF file

doc.Save(myDir + “TexttoPDF.pdf”);

Any news here?


We are afraid it has not been scheduled yet and is still pending for investigations. We will be informing here once any update will be available. We really appreciate the patience and comprehension in this regard.