VinuBibin
VinuBibin

Reputation: 785

showing emoji in pdf or excel

I have the data containing emoji in database. I want to display in the generated document such as pdf or in excel format.

I am using spring boot application. Please suggest any java library for generating either PDF or excel which supports emoji.

Upvotes: 0

Views: 3739

Answers (1)

Joris Schellekens
Joris Schellekens

Reputation: 9032

iText supports this. Assuming

  • your emoji is a unicode character
  • you use a font that contains the correct glyph for this unicode character

Best way to test this is to try it.

This is how to get started with iText:

https://developers.itextpdf.com/content/itext-7-jump-start-tutorial/installing-itext-7

And this is a small code-snippet that adds text to a document with different fonts:

PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
Document document = new Document(pdf);

PdfFont font = PdfFontFactory.createFont(FontConstants.TIMES_ROMAN);
PdfFont bold = PdfFontFactory.createFont(FontConstants.TIMES_BOLD);
Text title =
    new Text("The Strange Case of Dr. Jekyll and Mr. Hyde").setFont(bold);
Text author = new Text("Robert Louis Stevenson").setFont(font);
Paragraph p = new Paragraph().add(title).add(" by ").add(author);

document.add(p);
document.close();

For more information check out the tutorials. https://developers.itextpdf.com/content/itext-7-building-blocks/chapter-1

Upvotes: 1

Related Questions