我打算根据我从另一个文件中读取的值,为每个页面开始使用不同的字符串。我已将它放在我的 onStartPage 方法中,如下所示:
@Override
public void onStartPage(PdfWriter writer, Document output) {
try {
File finish = new File("C:/Statements final/");
File[] finf = finish.listFiles();
Font f1 = new Font(Font.NORMAL, 12);
f1.setColor(Color.BLACK);
String firstline = "";
for (int k = 0; k < filenames1.length; k++) {
FileInputStream fs = new FileInputStream("C:/Statements final/" + filenames1[k]);
BufferedReader br = new BufferedReader(new InputStreamReader(fs));
for (int i = 0; i < 0; i++) {
br.readLine();
}
firstline = br.readLine();
System.out.println(firstline);
output.add(new Paragraph(new Phrase(new Chunk(firstline, f1))));
}
} catch (Exception ex) {
System.out.println(ex);
}
}
我收到此 StackOverflow 错误:
Exception in thread "main" java.lang.StackOverflowError
at java.lang.String.toLowerCase(String.java:2524)
at com.lowagie.text.pdf.PdfEncodings.convertToBytes(PdfEncodings.java:149)
at com.lowagie.text.pdf.BaseFont.convertToBytes(BaseFont.java:795)
at com.lowagie.text.pdf.FontDetails.convertToBytes(FontDetails.java:160)
at com.lowagie.text.pdf.PdfContentByte.showText2(PdfContentByte.java:1386)
at com.lowagie.text.pdf.PdfContentByte.showText(PdfContentByte.java:1396)
at com.lowagie.text.pdf.PdfDocument.writeLineToContent(PdfDocument.java:1587)
at com.lowagie.text.pdf.ColumnText.go(ColumnText.java:841)
at com.lowagie.text.pdf.ColumnText.go(ColumnText.java:752)
at com.lowagie.text.pdf.PdfPRow.writeCells(PdfPRow.java:513)
at com.lowagie.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:511)
at com.lowagie.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:587)
at com.lowagie.text.pdf.PdfPTable.writeSelectedRows(PdfPTable.java:543)
at com.lowagie.text.pdf.PdfDocument.newPage(PdfDocument.java:830)
at com.lowagie.text.pdf.PdfDocument.carriageReturn(PdfDocument.java:1192)
at com.lowagie.text.pdf.PdfDocument.add(PdfDocument.java:482)
at estatement.Border.onStartPage(Border.java:112)
任何知道我应该做什么的人。