Remove the line:
Watermark watermark = new Watermark(img,1,1);
You only need to create the image once, probably in onStartDocument(). As it
is you'll have as many image instances as the number of pages.
Best Regards,
Paulo Soares
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]
> Sent: Tuesday, November 11, 2003 4:35
> To: [EMAIL PROTECTED]
> Subject: RE: [iText-questions] Problem with Watermark & Table/Cell
> Border
>
> Hi Paulo,
>
> I did that, but it didn't really work that well either when I use
> onStartPage. It seems like the first page renders correctly, but
> subsequent
> pages have the same issues where the watermark seems to be above the table
> in the z-ordering.
>
> Please find the attached document:
> (See attached file: draft.pdf)
>
> snipplet of my code:
>
> /**
> * onStartPage event
> */
> public void onStartPage(PdfWriter writer, Document document) {
> if (writer instanceof PdfWriter) {
> ((PdfWriter)writer).setMargins(48, 32, 32, 32);
>
> if (log.isDebugEnabled())
> log.debug("!!!!! onStartPage: setting page
> margin !!!!!!");
> }
>
> // Add the draft watermark if the document is a draft
> version.
> if(draft){
> if (log.isDebugEnabled())
> log.debug("???? SOAWriter ???? -> Adding
> Watermark...");
>
> try {
> Image img =
> Image.getInstance(FSRAConstants.HOME_DIR + "/images/draft.png");
> img.setAbsolutePosition(1,1);
>
> Watermark watermark = new Watermark(img,1,1);
> boolean isSuccessful = document.add(watermark);
>
> if (docWriter instanceof PdfWriter)
>
> ((PdfWriter)docWriter).getDirectContentUnder().addImage(img);
>
> if (!isSuccessful)
> log.warn("Add watermark failed....");
> }
> catch (Exception e) {
> log.error("ERROR: error occurred while adding
> watermark :" + e.getMessage());
> }
> } // if
> }
>
>
> Furthermore, I am using the XMLParser with the PdfWriter to generate the
> PDF document.
>
> What should I do next? Please advice. Thank you very much in advanced.
>
> Kindest Regards,
> Edward
>
>
>
> ----- Message from Paulo Soares <[EMAIL PROTECTED]> on Mon, 10 Nov 2003
> 18:25:34 -0000 -----
>
> To: 'Benjamin Bohlmann' <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED]
>
> Subject: RE: [iText-questions] Problem with Watermark & Table/Cell
> Border
>
>
> Use a PdfPTable and the problem will go away. Alternatively put the image
> in
> an onStartPage event in a PdfWriter.getDirectContenUnder().
>
> Best Regards,
> Paulo Soares
>
>
> > -----Original Message-----
> > From: Benjamin Bohlmann [SMTP:[EMAIL PROTECTED]
> > Sent: Monday, November 10, 2003 13:38
> > To: [EMAIL PROTECTED]
> > Subject: [iText-questions] Problem with Watermark & Table/Cell
> Border
> >
> > Hi,
> >
> > I hope that someone can help me on this. I want to generate a PDF using
> > itext that contains a table with borders and has a
> > background-image/watermark. It works fine as long as the table isn't
> above
> > the watermark. In that case the part of the table border that is
> supposed
> > to be above the image is covered by it (only the part above/below the
> > image and not the entire border). The text within the cells shows up
> fine.
> >
> >
> > Some java source illustrating my problem is attached below. I already
> > tried setting the watermarks alignment to Watermark.UNDERLYING, but that
> > didn't help.
> >
> > thanks in advance,
> > Benjamin Bohlmann
> >
> >
> > The source:
> >
> > Document doc = new Document(PageSize.A4);
> > PdfWriter writer = PdfWriter.getInstance(doc,new
> > FileOutputStream("foo.pdf"));
> >
> > Watermark wm = new Watermark(Image.getInstance("foo.gif"),0,0);
> > doc.add(wm);
> >
> > doc.open();
> >
> > Table t = new Table(3);
> > t.setBorderWidth(2);
> >
> > Cell c = new Cell("foobar");
> > c.setBorderWidth(3);
> > t.addCell(c);
> >
> > c = new Cell("foobar");
> > c.setBorderWidth(3);
> > t.addCell(c);
> >
> > c = new Cell("foobar");
> > c.setBorderWidth(3);
> > t.addCell(c);
> >
> > doc.add(t);
> >
> > doc.close();
> >
>
>
> __________________________________________________________________________
> _____
> Unencrypted electronic mail is not secure and may not be authentic.
> If you have any doubts as to the contents please telephone to confirm.
>
> This electronic transmission is intended only for those to whom it is
> addressed. It may contain information that is confidential, privileged
> or exempt from disclosure by law. Any claim to privilege is not waived
> or lost by reason of mistaken transmission of this information.
> If you are not the intended recipient you must not distribute or copy this
> transmission and should please notify the sender. Your costs for doing
> this will be reimbursed by the sender.
> __________________________________________________________________________
> _____
> << File: draft.pdf >>
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions