PdfDocument pdfDoc = new PdfDocument(new PdfWriter(DEST));
Document doc = new Document(pdfDoc);
doc.setMargins(0,0,0,0);
for (int i = 0; i <20 ; i++) {
Paragraph element = new Paragraph("p " + i);
if(i!=0) {
element.setPadding(0);
element.setMargin(0);
element.setFixedLeading(255);
doc.add(element);
}
}
How do I remove the indent from the top of the first line?
You don't draw the first line (for i=0
) at all, so for all lines you do draw you have explicitly set a leading.
To also draw the first line, move the doc.add
out of the if
body:
for (int i = 0; i <20 ; i++) {
Paragraph element = new Paragraph("p " + i);
if(i!=0) {
element.setPadding(0);
element.setMargin(0);
element.setFixedLeading(255);
}
doc.add(element);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.