0

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();
} 
namita
  • 1
  • 3
  • Are you already creating the PDFs somehow and your problem is on how to watermark them?! – Lipis Mar 22 '14 at 21:53
  • i am creating pdf using response.getOutputStream. When i run this servlet, it creates pdf and shows dialog to download it. Now I just wants to watermark before it ask to download. Is it possible? plz help soon... thanks – namita Mar 24 '14 at 06:05
  • Yup.... I got perfect solution of my query on link http://stackoverflow.com/questions/21374006/add-page-number-to-pdf-using-pdfstamperitext?rq=1 Thanks – namita Mar 24 '14 at 07:30
  • So if you got your solution.. you could delete this questions then, as it's not adding anything to SO.. – Lipis Mar 24 '14 at 11:36

0 Answers0