itext headerfooter - 페이지 번호가 다음 줄에 나타납니다.
문제
헤더 풋 객체를 사용하여 itext로 헤더를 만들고 있습니다.
첫 번째 줄에 충분한 공간이 있지만, 페이지 번호는 항상 헤더의 두 번째 줄에 나타납니다.
이 문제는 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
해결책
관심있는 모든 사람들에게 나는 그것을 알아 냈습니다. 단락에서 헤더 풋 매개 변수를 문구로 변경하면 문제가 해결되었습니다.
이 선을 변경하십시오 :
HeaderFooter header = new HeaderFooter(new Paragraph(headString, iTextHeadingFont), true);
이에:
HeaderFooter header = new HeaderFooter(new Phrase(headString, iTextHeadingFont), true);
닫힌 문제!
제휴하지 않습니다 StackOverflow