iText:单元格内容短语不存在
当我调用iText:单元格内容短语不存在,itext,Itext,当我调用 public class App { public static void main( String[] args ) { try { TemplateGenerator tg = new TemplateGenerator(); tg.generateTemplateFile(); } catch (IOException e) { e.printStackTrace(); } catch (Docume
public class App
{
public static void main( String[] args )
{
try {
TemplateGenerator tg = new TemplateGenerator();
tg.generateTemplateFile();
} catch (IOException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}
}
及
}
我打印了单元格,但它是空的,即没有“aaa”字样。无论什么样的单元格文本都不会出现。我想知道什么是错的没有错误。我得到了存储在src/main/resources中的文件,拥有664个访问权限。怎么了?没有字体会发生什么?您可能需要使用setColor方法初始化或更改其颜色。我使用的是5.4.5 iText。官方示例运行良好,工作完美。我刚刚对它进行了测试。这个问题中所声称的不是真的,或者问题中没有解释其他内容。我将文件存储在src/main/resources中-你是指java代码?还是结果pdf?通常都没有意义。actuar正如所发生的那样,这是Evice 3.10版的问题,而不是iText
public class TemplateGenerator {
Font cellTitle=null;
public void generateTemplateFile() throws IOException, DocumentException {
File file = new File(Properties.TEMPLATE_FILE);
file.getParentFile().mkdirs();
this.createPdf(Properties.TEMPLATE_FILE);
}
private void createPdf(String dest) throws IOException, DocumentException {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(dest));
document.setPageSize(this.setupPageSize(Properties.WIDTH_MM,
Properties.HEIGHT_MM));
document.setMargins(2, 2, 2, 2);
document.open();
document.add(buildFrames());
document.close();
}
private Rectangle setupPageSize(Float width, Float height){
return new Rectangle( Utilities.millimetersToPoints(width),
Utilities.millimetersToPoints(height));
}
private void setupFonts() throws IOException, DocumentException {
cellTitle = new Font(Font.FontFamily.HELVETICA, 13, Font.NORMAL, GrayColor.GRAYBLACK);
}
private PdfPTable buildFrames(){
PdfPTable table;
table = null;
try{
Font fontH1 = new Font(Font.FontFamily.COURIER, 16, Font.NORMAL);
table = new PdfPTable(1);
table.addCell(new PdfPCell(new Phrase("aaa",fontH1)));
}catch (Exception e){
e.printStackTrace();
}
return table;
}