POI - Importing new fonts to the POI

给你一囗甜甜゛ 提交于 2019-12-24 13:33:38

问题


How can i import a new font to POI API with extensions ttf & otf , without install these fonts into the environment ?

Is there a jar that i should update it with the path of the new font ?


回答1:


Normally

You cannot add fonts... You can think your (office) files just like HTML. Font lives outside the document. You just set the font name, family, etc.

Update:

However, someone has already tried to do that. Using embedded files, you could add font files.

Link:

http://apache-poi.1045710.n5.nabble.com/Font-embedding-into-XSLF-td5713937.html

It is far from easy. There's no easy way to insert embedded files.

  • Embed files into Excel using Apache POI
  • Embedding HSSF(excel) into HSLF(ppt) using apache poi



回答2:


In the meantime I've implemented an API to embed the fonts easily. This version goes live with POI 4.1.0.

POI can't consume .ttf/.otf directly, but needs some help from googles sfntly. My demo project can be found under github/poi-font-mbender.

I won't provide a copy & paste of the sample class as you also need the rest of the sfntly library, which is not available as maven artifact.



来源:https://stackoverflow.com/questions/22453259/poi-importing-new-fonts-to-the-poi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!