Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5839917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:39:37+00:00 2026-05-22T11:39:37+00:00

Wonder if this possible. Saw many posts on adding watermark after the pdf is

  • 0

Wonder if this possible. Saw many posts on adding watermark after the pdf is created and saved in disk. But during creation of document how do i add a image watermark. I know how to add a image to document. But how do i position it such that it comes at the end of page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:39:39+00:00Added an answer on May 22, 2026 at 11:39 am

    This is essentially identical to adding a header or footer.

    You need to create a class that implements PdfPageEvent, and in the OnPageEnd, grab the page’s PdfContentByte, and draw your image there. Use an absolute position.

    Note: You probably want to derive from PdfPageEventHelper, it has empty implementations of all the page events, so you just need to write the method you actually care about.

    Note: Unless your image is mostly transparent, drawing it on top of your page will cover up Many Things. IIRC (“If I Recall Correctly”), PNG and GIF files added by iText will automatically be properly masked, allowing things under them to show through.

    If you want to add an opaque image underneath everything, you should override OnStartPage() instead.

    This is Java, but converting it is mostly a matter of capitalizing method names and swapping get/set calls for property access.

    Image watermarkImage = new Image(imgPath);
    watermarkImage.setAbsolutePosition(x, y);
    
    writer.setPageEvent( new MyPageEvent(watermarkImage) );
    
    
    public MyPageEvent extends PdfPageEventHelper {
      private Image waterMark;
      public MyPageEvent(Image img) {
        waterMark = img;
      }
      public void OnEndPage/*OnStartPage*/(PdfWriter writer, Document doc) {
        PdfContentByte content = writer.getContent();
        content.addImage( waterMark );
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, this is possibly borderline-subjective, but I wonder where one would put a simple
I know that this is somewhat subjective, but I wonder if there is a
I haven't play enough with this and usually use mocks, but I wonder what
Has anyone used TUDBC ? This looks interesting, but I wonder how valuable it
I wonder if this is possible with ant and java : I have a
i wonder if this is possible with simple css or if i have to
I wonder if this is possible with straight SQL on MySQL. I need to
I wonder if this is possible in jaxb2. I have a xml that can
Hi (sorry for my ugly english) I wonder if this is possible to retrieve
I wonder if this would be doable ? To insert an array into one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.