im generating a PDF file with some comments, cells, tables... Im working with PDFbox in JAVA
I would like to add a line break to my string which its called "escComments" and it contain an array of Comments.
I've tried "\n", "\r", "System.getProperty(“line.separator”)" and nothing works.
This is my code:
if (action.getCloseComment() != null) {
String escComments = action.getCloseComment();
escComments = escapeChars(escComments);
row.put( "COMENTARIOS", escComments);
}
I would like to add a line break for each comment comming from getCloseComment()
try (PDPageContentStream contents = new PDPageContentStream(doc, page))
{
PDFont font = PDType1Font.HELVETICA;
contents.beginText();
contents.setFont(font, 12);
contents.newLineAtOffset(100, 700);
contents.showText(line1);
contents.newLineAtOffset(0, -50);
contents.showText(line2);
contents.newLineAtOffset(0, -50);
contents.showText(line3);
contents.endText();
}
you can try 'moveTextPositionByAmount' to split string and move the text position to next line.
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.