以pdf或excel显示表情符号 [英] showing emoji in pdf or excel

查看:919
本文介绍了以pdf或excel显示表情符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有包含表情符号的数据。我想在生成的文档中显示,如pdf或excel格式。

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

我正在使用spring boot应用程序。请建议任何用于生成支持表情符号的PDF或Excel的java库。

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

推荐答案

iText支持此功能。假设

iText supports this. Assuming


  • 你的表情符号是一个unicode字符

  • 你使用的字体包含正确的字形这个unicode字符

测试这个的最佳方法就是尝试它。

Best way to test this is to try it.

这是如何开始使用iText:

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();

有关详细信息,请查看教程。
https://developers.itextpdf.com/ content / itext-7-building-blocks / chapter-1

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

这篇关于以pdf或excel显示表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆