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

  • SEARCH
  • Home
  • 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 8862935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:51:01+00:00 2026-06-14T15:51:01+00:00

I am creating a PDF using the iText Library and not been able to

  • 0

I am creating a PDF using the iText Library and not been able to set the background image for Table in PDF.

like below imageenter image description here

Edit

Currently i am using this to set Background , its setting image to absolute position , i want to set it relative to table

class CellBackgroundPic  implements PdfPTableEvent {

Activity mActivity;
public CellBackgroundPic (Activity Activity){

    this.mActivity=Activity;

}
Image bgImage;


public void tableLayout(PdfPTable table, float[][] widths, float[] heights,
        int headerRows, int rowStart, PdfContentByte[] canvases){
    PdfContentByte pdfContentByte = canvases[PdfPTable.BACKGROUNDCANVAS];
    Drawable   myImage  = mActivity.getResources().getDrawable(R.drawable.table_bg);

      Bitmap bitmap = ((BitmapDrawable) myImage).getBitmap();
       ByteArrayOutputStream stream = new ByteArrayOutputStream();
       bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
       byte[] bitmapdata = stream.toByteArray();
       try {
        bgImage = Image.getInstance(bitmapdata);
        bgImage.setAbsolutePosition(330f, 642f);
        pdfContentByte.addImage(bgImage);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
}
  • 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-06-14T15:51:03+00:00Added an answer on June 14, 2026 at 3:51 pm

    There are different approaches possible.

    One would be to use a pattern color created with an image and use that pattern color as background color. However, that doesn’t seem to be a match with what you need.

    Based on your example I would suggest using a table event as demonstrated here:
    http://itextpdf.com/examples/iia.php?id=93

    In this example, the background color of the rows is drawn in the tableLayout() method. You need to adapt this method and instead of drawing colored rectangles, you need to add an image at the appropriate coordinates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating some PDF reports using iText in Java. According to the requirements,
I need a PDF library for manipulating a PDF documents, (creating PDF, image convertinng
I'm creating a PDF using Flying Saucer (which dumps out CSS/HTML to iText to
I am using iText library to print certain data in table format in a
We are dynamically creating PDF using itext in our application. The content of the
Language : ASP.NET/VB.NET I am creating pdf file using itextsharp library. On my development
I'm creating a pdf file using BIRT reporting library. Later I need to digitally
I'm creating a Java app that creates 4 PDF files using iText. On the
I'm using html2fpdf for creating PDF documents. Now once I have created that, I
We are creating PDF documents on the fly from the database using PDFsharp .

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.