所以我刚刚听说有关称为iText的API,我并不真正熟悉它的使用。用servlet写一个pdf文件(模板)
所以我现在的问题是我想写一个现有的PDF文件(模板)在jsp形式提供的信息。 我尝试了一些在互联网上找到的代码,它工作正常,但没有在servlet上。 谢谢。
编辑这里是我发现并试图放入servlet的代码。
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Document document = new Document(PageSize.A4);
try {
PdfWriter.getInstance(document, new FileOutputStream(new File(
"test.pdf")));
document.open();
String content = request.getParameter("aa");
Paragraph paragraph = new Paragraph(content);
document.add(paragraph);
} catch (DocumentException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
document.close();
}
}
你可以分享你的尝试吗? – soorapadman
_I尝试在互联网上找到一些代码_ - 告诉我们你在哪里找到该代码,以便我们也可以尝试。 –
我相应地更新了我的帖子。 –