What replaces chunk in iText 7?

随声附和 提交于 2020-01-03 07:30:03

问题


Attempting to use iText 7 in java. Want to have part of a paragraph be bold. Apparently in earlier releases this was done by formatting "chunks" separately then adding them to the paragraph. Apparently "chunks" don't exist in iText 7. What is the procedure for iText 7?


回答1:


Text in com.itextpdf.layout.element is meant to be an alternative for Chunk.

To make a part of a paragraph bold, you would need a bold font to be specified for a piece of a text.

Paragraph p = new Paragraph();
p.add(new Text("this will be in bold").setFont(boldFont));

Alternatively, you can rely on iText to simulate bold for regular font, but this is not a preferred way.

p.add(new Text("bold will be simulated for regular font").setBold());

Please check out the jumpstart tutorial written by Bruno Lowagie.



来源:https://stackoverflow.com/questions/37501128/what-replaces-chunk-in-itext-7

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