0

I am using a very very old version of itext (1.4.1). Everything works fine, but I want to add the header and footer on every page of the pdf-document, instead of only at the top and bottom of the document.

I figured I have to do this before I open the document. However, I can not add images before I open the document, only watermarks. But a watermark is behind the rest of the text...

Is there anyway to do this?

  Document document = new Document();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();

  try {
        PdfWriter.getInstance(document, baos);
        Image image = getImage(IMAGE_NAME_LOGO);
        Chunk chunk =  new Chunk(image, 0,0);
        HeaderFooter footer = new HeaderFooter(new Phrase(chunk), null); //error here
        document.open();
        document.add(text);
        (..)
  }  
TorK
  • 567
  • 2
  • 10
  • 27
  • This is definitely a duplicate of [How to add an image in all pages of PDF?](http://stackoverflow.com/questions/21908651/add-an-image-in-all-pages-of-pdf) However, it is not sure if this will work in the obsolete version of iText that you are using. iText 1.4.1 dates from May 22nd, 2006. Please maintain your software and upgrade! You are using a version you should no longer use! See also http://stackoverflow.com/questions/25696851/can-itext-2-1-7-or-earlier-can-be-used-commercially – Bruno Lowagie Feb 04 '15 at 13:32
  • I notice that you have been asking other questions about iText and it seems that you are only just starting to use iText. May I ask why you would choose a version of iText that is almost 9 years old? – Bruno Lowagie Feb 04 '15 at 13:38
  • I'm maintaining a system that was started on (by others) in 2007. I wish to add new functionality without recreating the entire part of the system. I will take a look at the link you posted, thank you. – TorK Feb 04 '15 at 13:53
  • It's a little bit late to start "maintaining", isn't it? I once had to do such a maintenance job. I used the new iText next to the old one, which works because the old iText uses package names starting with `com.lowagie` whereas the new iText start with `com.itextpdf`. This way, there are no conflicts between the two versions and I was able to gradually replace old iText code with new iText code without breaking anything. – Bruno Lowagie Feb 04 '15 at 13:56
  • hehe the itext parts are only a fraction of the system (creating pdf files of tickets). It has been working just fine all these years, and there was no need to do much work on it. Until this year, when we also wanted to create some sort of html-ticket as well (as stated in a previous question I had here on stack). I will implement a new library if necessary, for now this works fine :) – TorK Feb 04 '15 at 14:23

0 Answers0