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

Free Support Forum - aspose.com

Aspose HTML (Java): No Emojis in produced PDF

Aspose HTML (for Java) fails to render Emojis when converting this HTML (p:/tmp/originalFile.html):

<html>
 <body>
  Emojis: ๐Ÿ™‚๐Ÿค™๐Ÿค๐Ÿ––๐Ÿ‘‚๐Ÿ‘…๐Ÿ‘๐Ÿ‰๐Ÿฅ˜
 </body>
</html>

to PDF.

For example - Chrome browser renders the above HTML like:
Opened with Chrome.PNG (3.6 KB)

โ€ฆ while Aspose HTML shows only

Emojis:

string (without Emoji characters) after conversion to PDF.

The conversion was done using the following code:

import com.aspose.html.Configuration;
import com.aspose.html.Sandbox;
import com.aspose.html.drawing.Margin;
import com.aspose.html.drawing.Size;
import com.aspose.words.PaperSize;

import java.io.File;

class EmojiHtmlToPdf {

	public static void main(String[] args) {
		File inputFile = new File("p:/tmp/originalFile.html");
		File outputFile = new File("p:/tmp/convertedFile.pdf");


		com.aspose.html.HTMLDocument doc = new com.aspose.html.HTMLDocument(inputFile.getAbsolutePath());
		com.aspose.html.converters.Converter.convertHTML(doc, new com.aspose.html.saving.PdfSaveOptions(), outputFile.getAbsolutePath());
	}
	
}

Could you please give me some instruction of what would be a proper way for Emojis to show up in produced PDF?

Iโ€™ve also tried using the following Twitter (Mozilla) Emoji font:

With that in mind Iโ€™ve changed the HTML accordingly:

<html>
 <body style="font-family: Arial, sans-serif, 'Tweemoji Mozilla'">
  Emojis: ๐Ÿ™‚๐Ÿค™๐Ÿค๐Ÿ––๐Ÿ‘‚๐Ÿ‘…๐Ÿ‘๐Ÿ‰๐Ÿฅ˜
 </body>
</html>

, placed TwemojiMozilla.ttf inside โ€œp:/tmp/โ€ folder and then run the conversion like:

File inputFile = new File("p:/tmp/originalFile.html");
File outputFile = new File("p:/tmp/convertedFile.pdf");

// Set TwemojiMozilla.ttf font (which is placed inside tmp folder):
new FontsSettings().setFontsLookupFolders(new String[]{ "p:/tmp/"}, true);

// Convert HTML to PDF
com.aspose.html.HTMLDocument doc = new com.aspose.html.HTMLDocument(inputFile.getAbsolutePath());

com.aspose.html.converters.Converter.convertHTML(doc, new com.aspose.html.saving.PdfSaveOptions(), outputFile.getAbsolutePath());

Unfortunately the results were even worse:
image.png (704 Bytes)

Any help with this is highly appreciated.

@PrimosK

We have logged an issue as HTMLJAVA-831 in our issue tracking system to further investigate this scenario. We will look into its details and keep you posted with the status of ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

So at the moment there is no way to show Emojis?

@PrimosK

We need to investigate the PDF Export functionality of the API in order to further check whether it is possible or not. Which is why we logged the investigation ticket. As soon as the ticket is investigated, we will be able to share some feedback with you. Please give us some time.

We are sorry for the inconvenience.