我的英语不好意思.
我正在尝试使用PdfPTable(iText库)创建表.
表格为我显示了空列![在此处输入图片描述] [1]
public class CreatePDF {
File file;
BaseFont bf;
Font f_title;
Font f_text;
public void setFont() throws DocumentException, IOException{
try{
bf = BaseFont.createFont("/fonts/Times_New_Roman.ttf", BaseFont.IDENTITY_H , BaseFont.EMBEDDED);
f_title = new Font(bf, 14 );
f_text = new Font(bf);
}catch(Exception ex){
ex.printStackTrace();
}
}
public void make_invoice() throws DocumentException, IOException{
setFont();
Document doc = new Document(PageSize.A4);
Desktop d = Desktop.getDesktop();
try{
file = new File("invoice.pdf");
PdfWriter.getInstance(doc, new FileOutputStream(file));
doc.open();
Paragraph title = new Paragraph();
title.setAlignment(Element.ALIGN_CENTER);
title.setFont(f_title);
title.add("Счет фактура");//this work!
doc.add(create_table());
doc.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
public PdfPTable create_table() throws DocumentException{
PdfPTable table = new PdfPTable(2);
table.setWidthPercentage(100);
table.setSpacingBefore(5f);
PdfPCell cell;
Phrase ph = new Phrase("Номер");//it's doesn't work ((
ph.setFont(f_text);
cell = new PdfPCell(ph);
table.addCell(cell);
table.addCell("Nuber");
return table;
}
我尝试使用其他字体但是对我没有帮助((((
我该如何解决这个问题?