Did you read the exception text? Did you look at the tutorial examples
on PdfStamper?
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of selvi
> Sent: Wednesday, September 13, 2006 7:45 AM
> To: itext
> Subject: [iText-questions] Fw:
> java.lang.UnsupportedOperationException:
>
>
> Hi,
>
>
> when i execute the code listed .l iam getting below listed error.
>
> ERROR:
>
> C:\jerry>java ImageLink
> java.lang.UnsupportedOperationException: Use
> PdfStamper.getUnderContent() or PdfStamper.getOverContent()
> at
> com.lowagie.text.pdf.PdfStamperImp.getDirectContent(PdfStamper
> Imp.java:1365)
> at ImageLink.main(ImageLink.java:36)
>
>
> code:
>
>
> import java.io.FileOutputStream;
>
> import java.util.HashMap;
>
> import com.lowagie.text.Element;
>
> import com.lowagie.text.Image;
>
> import com.lowagie.text.PageSize;
>
> import com.lowagie.text.Rectangle;
>
> import com.lowagie.text.pdf.BaseFont;
>
> import com.lowagie.text.pdf.PdfAnnotation;
>
> import com.lowagie.text.pdf.PdfAppearance;
>
> import com.lowagie.text.pdf.PdfContentByte;
>
> import com.lowagie.text.pdf.PdfFileSpecification;
>
> import com.lowagie.text.pdf.PdfReader;
>
> import com.lowagie.text.pdf.PdfStamper;
>
> /**
>
> * Reads the pages of an existing PDF file, adds pagenumbers
> and a watermark.
>
> */
>
> public class ImageLink {
>
> public static void main(String[] args) {
>
> try {
>
> // we create a reader for a certain document
>
> PdfReader reader = new PdfReader("page81.pdf");
>
> int n = reader.getNumberOfPages();
>
> // we create a stamper that will copy the document to a new file
>
> PdfStamper stamp = new PdfStamper(reader, new
> FileOutputStream("page81_new.pdf"));
>
> // adding some metadata
>
> HashMap moreInfo = new HashMap();
>
> moreInfo.put("Author", "Sundar");
>
> stamp.setMoreInfo(moreInfo);
>
> // adding content to each page
>
> int i = 1;
>
> // while (i < n) {
>
> ///i++;
>
> PdfContentByte cb = stamp.getWriter().getDirectContent();
>
> cb.rectangle(250/*left*/, 250/*top*/,250/*right*/, 250/*bottom*/);
>
> cb.stroke();
>
> Rectangle rect = new Rectangle(100/*left*/,
> 0/*top*/,350/*right*/, 350/*bottom*/);
>
> PdfFileSpecification pf =
> PdfFileSpecification.fileEmbedded(stamp.getWriter(),"attached
> image.JPG", "attached image.JPG", null);
>
> PdfAnnotation annot =
> PdfAnnotation.createFileAttachment(stamp.getWriter(),
> rect,"attached image.JPG", pf);
>
> PdfAppearance ap = cb.createAppearance(300, 300);
>
> ap.setBoundingBox(rect);
>
> ap.setLineWidth(1);
>
> annot.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, ap);
>
> annot.setAppearance(PdfAnnotation.APPEARANCE_DOWN, ap);
>
> annot.setPage();
>
> stamp.addAnnotation(annot, i);
>
> //}
>
> stamp.close();
>
> }
>
> catch (Exception de) {
>
> de.printStackTrace();
>
> }
>
> }
>
> }
>
>
>
>
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