-5

我有一个列表,我想创建一个 pdf 报告。用户可以通过单击按钮要求生成和下载 pdf 报告。我使用检票口框架。我应该怎么办?

4

1 回答 1

0

为什么不直接使用DownloadLinkModel生成文件的 a 呢?

IModel fileModel = new LoadableDetachableModel (){
    protected Object load() { 
        // A hello world PDF
        File f = File.createTempFile("tempFile", null);
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(f));
        document.open();
        document.add(new Paragraph("Hello World!"));
        document.close();
        return f;
    }
};

DownloadLink link = new DownloadLink(linkId, fileModel, "report.pdf");
// If you want to delete the file after it's been downloaded
link.setDeleteFileAfterDownload(true); 
add(link);

也看看:

于 2013-07-09T15:11:33.303 回答