iText RTF - 页脚上的文本无法正常工作

时间:2014-07-16 10:05:59

标签: java itext footer rtf

我希望在页脚内部显示带有-1的文本,但是我的代码不起作用(如果我在单词和页脚的主体内添加相同的短语,正文上的文本正确显示但页脚不在页脚上)。< / p>

这是我的代码:

BaseFont hbf = BaseFont.createFont("/Fonts/arial.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED);
Font fontArialHeaderFooter = new Font(hbf, 8, Font.NORMAL, Color.BLACK);

Phrase foot = new Phrase(
        "_________________________________________________________________________________________________________",
        fontArialHeaderFooter);
//Position of page number with \t
Phrase textFoot = new Phrase(
        "Carrer de la XXXX, 2\r\nXXXXX Barcelona\r\nTel. XX XXX XX XX\r\nFax. XX XXX XX XX\t\t\t\t\t\t\t\t\t\t\t       ",
        fontArialHeaderFooter);

foot.setLeading(-1);
textFoot.setLeading(-1);
foot.add(textFoot);

//Add Phrase on footer with page number (attribute "true")
HeaderFooter footer = new HeaderFooter(foot, true);
word.setFooter(footer);

//Add same Phrase inside body of word document to compare body with footer
word.add(foot);

结果在这里: http://gyazo.com/14e94a3297b273a91af8a5e5bf88b84f.png

为什么页脚无法正确显示,我该如何解决?

0 个答案:

没有答案