Watermarking dynamically created pdf's in google app engine

251 Views Asked by At

How can we watermark dynamically created pdf's in google app engine using Java/Netbeans? GAE does not support FileOutputStream. I tried PdfStamper but it doesn't support FileOutputStream. servlet code is below

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, Exception { String fileName="abc.pdf"; response.setContentType("application/pdf"); 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();
} 
0

There are 0 best solutions below