Sorry forgot to mentions the iText version. I am using iText-5.0.5.
-Susheela
On Mon, May 28, 2012 at 6:16 PM, Susheela Sundar <sushe...@pandesa.com>wrote:
> Hi,
>
> I am not able to watermark some of the scanned PDF documents and it does
> not give any error. The same code works fine for other PDF documents.
> The sample java code snippet used for watermarking is given below:
>
> String filePath = "E:\\inputfile.pdf";
> String tempFilePath = "E:\\outputfile.pdf";
> PdfReader reader = new PdfReader(filePath);
> int n = reader.getNumberOfPages();
> PdfStamper stamper = new PdfStamper(reader, new
> FileOutputStream(tempFilePath));
> // watermarkText = watermarkText.toUpperCase();
> PdfContentByte under;
> PdfGState gstate = new PdfGState();
> gstate.setFillOpacity(0.35f);
> gstate.setStrokeOpacity(0.35f);
> BaseFont font = BaseFont.createFont(BaseFont.HELVETICA_BOLD,
> BaseFont.WINANSI,
> BaseFont.NOT_EMBEDDED);
> int fontSize = 60;
> Rectangle size = reader.getPageSizeWithRotation(1);
> float angle = (float) ((180 * (Math.asin(size.getHeight()
> / Math.sqrt(size.getWidth() * size.getWidth() +
> size.getHeight() * size.getHeight())))) / Math.PI);
> int i=1;
> while (i < n+1) {
> under = stamper.getOverContent(i);
> under.setColorStroke(new BaseColor(127, 127, 255));
> i++;
> under.beginText();
>
> under.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_STROKE);
> under.setLineWidth(0.85f);
> //under.setLineDash(0.3f,0.3f);
> under.setLineDash(0.4f, 0.4f, 0.2f);
> under.setFontAndSize(font, fontSize);
> String lineText = " Watermarking test ";
> under.showTextAlignedKerned(Element.ALIGN_BOTTOM, lineText,
> 60, 120, angle);
> under.endText();
> }
> stamper.close();
> }
>
> What might be the problem in watermarking?
>
> Thanks,
> Susheela
>
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php