Itext:将元素添加到新页面时添加新行

时间:2022-10-02 21:11:15

i am adding an element to itext pdf using code:

我正在使用代码向itext pdf添加一个元素:

((com.itextpdf.text.pdf.PdfPTable) element).setKeepTogether(true);
document.add(element);

One of the element text is of 2 pages and hence it is added to second page. But on second page I want to leave first 2 lines blank for adding header. Any suggestion how can i leave 2 lines blank of the new page?

其中一个元素文本是2页,因此它被添加到第二页。但在第二页我想留下前两行空白以添加标题。任何建议我怎么能留下新页面的2行空白?

2 个解决方案

#1


2  

I have found my answer instead of using Document document = new Document(); , I used Document document = new Document(PageSize.LETTER,30,30,60,35)

我找到了答案而不是使用Document document = new Document(); ,我用Document document = new Document(PageSize.LETTER,30,30,60,35)

#2


0  

Try add Paragraph:

尝试添加段落:

document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));

#1


2  

I have found my answer instead of using Document document = new Document(); , I used Document document = new Document(PageSize.LETTER,30,30,60,35)

我找到了答案而不是使用Document document = new Document(); ,我用Document document = new Document(PageSize.LETTER,30,30,60,35)

#2


0  

Try add Paragraph:

尝试添加段落:

document.add(new Paragraph("\n"));
document.add(new Paragraph("\n"));