0
我試圖用Java創建一個利用iText 7 PDF文檔。但是表格內容沒有顯示在pdf中。iText的7:表的內容是沒有得到顯示
代碼段:
private void addReceiptDetails(Document doc) {
Table table = new Table(2, true);
table.addCell(new Cell().add("C1"));
table.addCell(new Cell().add("C2"));
for (TaxTypeModel taxType : sale.getTaxModel().getTaxTypeModelList()) {
table.addCell(new Cell().add("C9"));
table.addCell(new Cell().add("C10"));
}
table.addCell(new Cell().add("C3"));
table.addCell(new Cell().add("C4"));
table.addCell(new Cell().add("C5"));
table.addCell(new Cell().add("C6"));
table.addCell(new Cell().add("C7"));
table.addCell(new Cell().add("C8"));
doc.add(table);
table.complete();
doc.close();
}
PDF表的內容:
有人可以請幫我在這裏。我不確定這裏到底出了什麼問題。
編輯:我嘗試了代碼示例從here:
Table table = new Table(8);
for (int i = 0; i < 16; i++) {
table.addCell("hi");
}
doc.add(table);
而這也只是創造空單元格。
非常感謝你的幫助。我花了很多時間一個可怕的量來解決這個問題。我現在可以解決它。 我不得不爲每個單元添加'.setFontColor(Color.BLACK)'。 我將頁面背景圖片設置爲LIGHT_GRAY,也許這就是爲什麼默認顏色不可見的原因。 –
*「我必須爲每個單元格添加'.setFontColor(Color.BLACK)」* - 我假設有一個更簡單的解決方案,或許您只需在正確的位置將填充顏色設置爲黑色即可...... – mkl