Example #1
0
 // FIXME: Manage Exceptions
 private OutputStream marcarReporteProgramaRechazado(final Programa programa, InputStream src)
     throws IOException, DocumentException {
   PdfReader reader = null;
   reader = new PdfReader(src);
   int n = reader.getNumberOfPages();
   ByteArrayOutputStream os = new ByteArrayOutputStream();
   PdfStamper stamper = null;
   stamper = new PdfStamper(reader, os);
   // text watermark
   Font f = new Font(Font.FontFamily.HELVETICA, 65);
   Phrase p = new Phrase("RECHAZADO", f);
   // transparency
   PdfGState gs1 = new PdfGState();
   gs1.setFillOpacity(0.3f);
   // properties
   PdfContentByte over;
   Rectangle pagesize;
   float x, y;
   // loop over every page
   for (int i = 1; i <= n; i++) {
     pagesize = reader.getPageSizeWithRotation(i);
     x = (pagesize.getLeft() + pagesize.getRight()) / 2;
     y = (pagesize.getTop() + pagesize.getBottom()) / 2;
     over = stamper.getOverContent(i);
     over.saveState();
     over.setGState(gs1);
     ColumnText.showTextAligned(over, Element.ALIGN_CENTER, p, x, y, 45);
   }
   stamper.close();
   reader.close();
   return os;
 }