找不到符号getInstance NetBeans

时间:2016-09-16 12:34:26

标签: java netbeans

我正在尝试将JPanel转换为pdf文件。我犯了一个错误

getInstance() method is a unknown symbol

代码:

Document document = new Document();
    try {
        PdfWriter writer;
        writer = PdfWriter.getInstance(document, new FileOutputStream("C:\test.pdf"));
        document.open();
        PdfContentByte contentByte = writer.getDirectContent();
        PdfTemplate template = contentByte.createTemplate(500, 500);
        Graphics2D g2 = template.createGraphics(500, 500);
        panelBill.print(g2);
        g2.dispose();
        contentByte.addTemplate(template, 30, 300);
    } catch (Exception e) {
        e.printStackTrace();
    }
    finally{
        if(document.isOpen()){
            document.close();
        }
    }

0 个答案:

没有答案