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 8022589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:18:25+00:00 2026-06-04T22:18:25+00:00

I am having real problems, I have a cell with a phrase, and I

  • 0

I am having real problems, I have a cell with a phrase, and I want a small icon to the left of the phrase, but each element is being rendered on a new line

here is my code that returns the cell:

var cell = new PdfPCell();
Bitmap bitmap = new Bitmap(21, 21);
Graphics g = Graphics.FromImage(bitmap);

g.Clear(Color.White);

SolidBrush brush = new SolidBrush(colour);
g.FillEllipse(brush, 0, 0, 20, 20);
brush.Dispose();

g.DrawImageUnscaled(bitmap, 0, 0);

g.Dispose();

var imgIcon = iTextSharp.text.Image.GetInstance(bitmap, System.Drawing.Imaging.ImageFormat.Jpeg);
bitmap.Dispose();
//imgIcon.Alignment = iTextSharp.text.Image.TEXTWRAP | iTextSharp.text.Image.ALIGN_RIGHT;
cell.AddElement(imgIcon);

var phrase = new Phrase(o.ToString(), Report.Fonts.Table);
cell.AddElement(phrase);

//this code scales the image so that it does not fit the cell
foreach (IElement element in cell.CompositeElements)
{
     PdfPTable tblImg = element as PdfPTable;
     if (tblImg != null)
     {
         tblImg.TotalWidth = 10;
         tblImg.LockedWidth = true;
     }
}
return cell;

here is the output:

enter image description here

any help would be greatly appreciated

–edit:
here is the output with imgIcon’s alignment property set

enter image description here

  • 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-04T22:18:26+00:00Added an answer on June 4, 2026 at 10:18 pm

    The iTextSharp Image object is displayed as a block element (in CSS terms). You need to explicitly wrap the Image in a Chunk to get inline display, something like this:

    PdfPTable table = new PdfPTable(1) {
      TotalWidth = 100, LockedWidth = true, 
      HorizontalAlignment = Element.ALIGN_LEFT
    };
    PdfPCell cell = new PdfPCell();
    Phrase p = new Phrase(new Chunk(image, 0, 0));
    p.Add(new Phrase("Print"));
    cell.AddElement(p);
    table.AddCell(cell);
    
    cell = new PdfPCell();
    p = new Phrase(new Chunk(image, 0, 0));
    p.Add(new Phrase("A long phrase that will make the PdfPCell wrap it's containing text."));
    cell.AddElement(p);
    table.AddCell(cell);
    document.Add(table);
    

    Code snippet result:

    Code snippet result

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

Sidebar

Related Questions

I have a multi-column layout in a UIWebview (webkit control) but I'm having problems
I have been having real problems getting the WPF designer to work in VS
This is a imaginary problem, but I'm having real problems with patches. Let's say
I'm having real problems tracking down why my UIView isn't deallocing. I have a
I'm having some real problems with this prepared statement and I have no idea
I'm having real problems getting PDO_MYSQL working. I started by just trying to install
I've been having real problems trying to get a ruby script to run through
I am having real problems trying debug my code to malfunctioning print statements. I
First time cake user and I'm having real apache problems. For some reason the
I am having real troubles adding a UIImageView to a single UITableView cell. In

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.