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

Free Support Forum - aspose.com

Set UTF8 Encoding & Transform MHT File with Chinese Characters to PDF | C# .NET

Hi,

I’m using Aspose.Net nuget C#, and a want to convert MHT file to PDF.
In my case, the MHT is converting to PDF but all the page contain “chinese” caracteres

code :

var doc = new Aspose.Words.Document(inStream);
doc.Save(outStream, Aspose.Words.SaveFormat.Pdf);

With the online converter the render is good : https://products.aspose.app/pdf/fr/conversion/mht

Using : aspose.pdf\21.6.0

Thx
Eric

@ericbesson,

We have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-22549. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Also, please check the following C# code of Aspose.Words for .NET API that you can use as a workaround?

HtmlLoadOptions opts = new HtmlLoadOptions();
opts.LoadFormat = LoadFormat.Mhtml;
Document doc = new Document("C:\\Ajout MHT d'indisponibilité du candidat en TT ROUAUD Gregory de l'agence RENNES FREVILLE.mht", opts);
doc.Save("C:\\21.7.pdf");
1 Like

@ericbesson,

Regarding WORDSNET-22549, we suggest you to please define encoding explicitly because it is not always possible to automatically detect encoding correctly.

LoadOptions opts = new LoadOptions();
opts.Encoding = Encoding.UTF8;
Document doc = new Document("C:\\Ajout MHT d'indisponibilité du candidat en TT ROUAUD Gregory de l'agence RENNES FREVILLE.mht", opts);
doc.Save("C:\\21.7.pdf");

Hi @awais.hafeez , it’s works with opts.LoadFormat = LoadFormat.Mhtml;

Thx

@ericbesson,

It is great that you were able to resolve the problem on your end. In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Words’ forum.

The issues you have found earlier (filed as WORDSNET-22549) have been fixed in this Aspose.Words for .NET 21.8 update and this Aspose.Words for Java 21.8 update.