将页面对齐在页面中央 [英] Align Paragraph at the center of the page
本文介绍了将页面对齐在页面中央的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用itext生成pdf文件。我想在页面中间对齐我的标题。目前我正在使用这样的
I am using itext to generate pdf file. I want to align my title in the middle of the page. Presently i am using like this
Paragraph preface = new Paragraph();
for (int i = 0; i < 10; i++) {
preface.add(new Paragraph(" "));
}
是否正确或是否还有其他最佳方式。
Is it correct or is there any another best way to do this.
推荐答案
使用 段落#setAlignment(int)
:
Paragraph preface = new Paragraph();
preface.setAlignment(Element.ALIGN_CENTER);
请参阅中的
ALIGN _ *
常量a href =http://developers.itextpdf.com/reference/com.itextpdf.text.Element> 元素
界面,了解更多可能的值。
See the ALIGN_*
constants in the Element
interface for more possible values.
这篇关于将页面对齐在页面中央的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文