日期:2014-05-17 浏览次数:20993 次
response.setContentType("text/html;charset=GBK"); response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".pdf"); OutputStream outs = response.getOutputStream(); // 获取输出流 PdfWriter writer = PdfWriter.getInstance(doc, outs); document.open(); PdfContentByte under = writer.getDirectContentUnder();
//添加水印 under.beginText(); under.setColorFill(BaseColor.LIGHT_GRAY); under.setFontAndSize(bfTitle, 100); under.setTextMatrix(70, 0); int rise = 200; for (int k = 0; k <waterMarkName.length(); k++) { under.setTextRise(rise); char c = waterMarkName.charAt(k); under.showText(c + " "); rise += 100; } under.endText(); document.close();//关闭