1
我很抱歉我的英語。 我想用PdfPTable(iText庫)創建表。 表給我空列![在這裏輸入的形象描述] [1]iText-PdfPTable不顯示西里爾文(俄語)符號
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;
}
我嘗試使用其他字體,但它並不能幫助我(((
我怎樣才能解決這個問題?
嘗試'新短語(「Номер」,字體)' – VahidN 2014-08-27 17:31:36
謝謝!爲什麼ph.setFont(f_text);不工作? – inoob 2014-08-27 17:38:36