我们如何使用Java / Netbeans在谷歌应用引擎中动态创建pdf水印?
GAE不支持FileOutputStream
。我尝试过PdfStamper,但它不支持FileOutputStream
。 servlet代码在
protected void doPost(HttpServletRequest请求,HttpServletResponse响应) 抛出ServletException,IOException,Exception { String fileName =" abc.pdf&#34 ;; response.setContentType("应用/ PDF&#34); response.setHeader(" Content-Disposition"," inline; filename = \"" + fileName +" \""); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document,response.getOutputStream());
document.open();
try {
Paragraph title1 = new Paragraph("Chapter 1", FontFactory.getFont(FontFactory.COURIER_OBLIQUE, 18, Font.BOLDITALIC, new CMYKColor(0, 255, 255,17)));
document.add(title1);
document.add(new Paragraph("Hi Namita, welcome to pdf generation"));
document.add(new Paragraph("Here we are creating pdf of records"));
document.add(new Paragraph("Please save records"));
} catch (Exception e) {
e.printStackTrace();
}
document.close();
}