Hi Paulo,
Thanks for your prompt reply.
Yes, I used PDFReader to get Document object. I am pasting my whole code for your reference.
Even I tested with PDFGSate and with over.setGState(gs)...could not get result.
----------Code----------------------------------------
Document document = new Document(PageSize.A4);
PdfReader reader = new PdfReader(args[0]);
int n = reader.getNumberOfPages();
// we create a stamper that will copy the document to a new file
PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(args[1]));
stamp.setEncryption(PdfWriter.STRENGTH128BITS, "", "", PdfWriter.AllowModifyAnnotations |
PdfWriter.AllowModifyContents);
// adding content to each page
int i = 0;
PdfContentByte over;
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);
float textBase = document.bottom() - 20;
while (i < n) {
i++;
over = stamp.getOverContent(i);
PdfGState gs = new PdfGState();
gs.setFillOpacity(0.8f);
over.setGState(gs);
over.beginText();
over.setTextMatrix(document.top(),document.bottom()-20);
over.setFontAndSize(bf,120);
over.setColorFill(Color.orange);
over.showTextAligned(Element.ALIGN_CENTER, "Final Copy ", document.getPageSize().width() / 2,
document.getPageSize().height() / 2, 55);
over.setFontAndSize(bf,20);
over.showTextAligned(Element.ALIGN_CENTER, "Contract Signature : XYZ Inc.1 and between IBM Corporation Ltd. United Status of Amrecia, USA ", document.getPageSize().width() / 2 + 50, document.getPageSize().height() /
2, 55);
over.showTextAligned(Element.ALIGN_CENTER, "Contract Signature : XYZ Inc.2 ",
document.getPageSize().width() / 2 + 80, document.getPageSize().height() / 2, 55);
over.showTextAligned(Element.ALIGN_CENTER, "Contract Signature : XYZ Inc.3 ",
document.getPageSize().width() / 2 + 105, document.getPageSize().height() / 2, 55);
over.endText();
}
stamp.close();
--------------------Code Ends---------------------------
Pranav
On Mon, 13 Nov 2006 Paulo Soares wrote :
>You need over.setGState(gs) to set the opacity but that's not the
>problem. Where do you get "document" from? PdfStamper doesn't have any.
>You should use PdfReader.getPageSize().
>
>Paulo
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On
> > Behalf Of pranav pandya
> > Sent: Monday, November 13, 2006 1:34 PM
> > To: [email protected]
> > Subject: [iText-questions] Transparancy Issue for showing
> > Text on Image
> >
> > Hi,
> >
> > I am a new member to this forum. I want to display a Text as
> > watermark on each page of iText. I have developed the code
> > for the same which shows things well for major pdfs. However
> > I am having one PDF which contains scan images only, no text.
> >
> > When I apply my code to generate the watermark to it, It does
> > not show the watermarked text on it.
> >
> > My code snippet for watermarking the text is
> >
> > //opacity settings
> >
> > PdfGState gs = new PdfGState();
> > gs.setFillOpacity(0.5f);
> >
> > while(i<totalpages)
> > //i is the page no...a loop through PDF pages
> > over = stamp.getOverContent(i);
> > over.beginText();
> >
> > over.setTextMatrix(document.top(),document.bottom()-20);
> > over.setFontAndSize(bf,120);
> >
> > over.setColorFill(Color.orange);
> > over.showTextAligned(Element.ALIGN_CENTER, "WaterMark
> > Test ", document.getPageSize().width() / 2,
> > document.getPageSize().height() / 2, 55);
> >
> > over.setFontAndSize(bf,20);
> >
> > over.showTextAligned(Element.ALIGN_CENTER, "Contract
> > Signature : Test Line 1 applied",
> > document.getPageSize().width() / 2 + 50,
> > document.getPageSize().height() / 2, 55);
> >
> > //text ends
> > over.endText();
> >
> > ------------------Code Ends
> >
> > I want to show above both lines as texts in every PDF page.
> > My PDF is containing only whole page scan images at each
> > page. No Text data it contains.
> >
> > Pls. help me how can I add watermarked text on such PDFs.
> >
> > Regds,
> > Pranav
> >
> >
> >
> > <http://adworks.rediff.com/cgi-bin/AdWorks/sigclick.cgi/www.re
> > diff.com/signature-home.htm/[EMAIL PROTECTED]>
> >
>
>
>Aviso Legal:
>Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.
>
>Disclaimer:
>This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.
>
>
>-------------------------------------------------------------------------
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>iText-questions mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/itext-questions
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
