2009-06-24 24 views
0

我正在用iText使用HeaderFooter对象创建一个标题。
尽管第一行有足够的空间,但页码始终出现在标题的第二行,并且我没有明确地在此处放置换行符。iText HeaderFooter - 页码出现在下一行

似乎只有从iText 1.2升级到iText 2.1.5时才会出现此问题,但我没有注意到iText源代码中的任何明显内容。

有没有其他人有这个问题,或知道如何解决它?

headString += viewReportTitle + "Page: "; 
//Setting the second param to true should append a page number at the end of the string 
HeaderFooter header = new HeaderFooter(new Paragraph(headString, iTextHeadingFont), true); 
header.setAlignment(Element.ALIGN_CENTER); 
iTextDoc.setHeader(header); 

输出显示如下:

Report Title Page: 
1 

回答

2

对于所有谁感兴趣的话,我想它了。通过将Paragraph中的HeaderFooter参数更改为Phrase,问题就解决了。

改变这一行:

HeaderFooter header = new HeaderFooter(new Paragraph(headString, iTextHeadingFont), true); 

要这样:

HeaderFooter header = new HeaderFooter(new Phrase(headString, iTextHeadingFont), true); 

问题关闭!

相关问题