什么可以替代iText 7中的块? [英] What replaces chunk in iText 7?

查看:91
本文介绍了什么可以替代iText 7中的块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在Java中使用iText 7.希望将段落的一部分加粗.显然,在较早的发行版中,这是通过分别格式化块"并将其添加到段落中来完成的.显然,iText 7中不存在块".iText7的程序是什么?

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?

推荐答案

Text旨在替代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));

或者,您可以依靠iText来模拟常规字体的粗体,但这不是首选方法.

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

请查看由Bruno Lowagie编写的 jumpstart教程.

Please check out the jumpstart tutorial written by Bruno Lowagie.

这篇关于什么可以替代iText 7中的块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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