« Return to Thread: Placing Image over an Image In a table in a PDF Using Itextsharp
1. Do you realize you are creating a separate instance of the mark.jpg for each page and a separate instance of grf.jpg for each cell? You should create those instances ONCE and reuse them on each page. It will make a smaller JPG file.
2. Apparently you wanted mark.jpg to show over top of the entire page, like a watermark. The recommended way to do that is with a PageEvent; in that page event, instead of adding to the Document, you would add the Image instance directly to the writer.DirectContentOver stream. But you can also do that without the PageEvent if you'd rather.writer.DirectContent.AddImage(png);
Image png = Image.GetInstance(str);
png.SetAbsolutePosition(350f, 498f);
// document.Add(png);
document.NewPage();
table = new PdfPTable(3);On Wed, Jun 25, 2008 at 5:37 PM, Manoop <manoop@...> wrote:
I want to create a PDF document using ItextSharp dll.
In that PDF, I want to place an image say A over an image say B in a table.
When I tried the image A is place under the Image B so it is not visible
properly
I want to place image A over B.
The code I write is place below.
Document document = new Document(pageSize);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream
("C:\\man\\headerTable.pdf", FileMode.Create));
document.Open();
string[] paramer ={"Game Intelligence:","Sense of Game
Reality:","Emotional Game Control:","Ability to Discern Goodfrom :","Overall
Attitude toward Sports:","Understanding Others:",
"Interpersonal Rapport:","Interpersonal
Harmony:","Interpersonal Conflict:","Underst Practical Team Action:","Team
Orientation:","Attitude toward Team Success:"
,"Attitude toward Team Failure:","Discipline,
Rules, & Game Plan :","Attitude toward Authority:",
"Attitude toward Compliance Benefits
","Attitude toward Rule-breaking:","Understanding Self Worth:","Sense of
Self Reality:",
"Emotional self control:","Ability to Discern
Personal Good from Bad:","Overall Self Attitude:","Awareness of
Self-worth:",
"Desire for Self Development:","Developing
Personal Potential (attitude):","Insight into Personal Problems
(attitude):",
"Game Role Awareness:","Game-role
Satisfaction:","Attitude toward Peak Performance:","Attitude toward Poor
Performance:",
"Sports Self-Identity:","Mental Toughness
(Discipline, Energy and Drive):","Understanding Self Worth:","Attitude
toward Personal Growth:",
"Attitude toward Personal
Regression:","Intuition:","Concentration:","Stress Tension
Indicator:","Stress Resistance:"};
PdfPTable table = new PdfPTable(3);
table.DefaultCell.Padding = 3;
float[] headerwidths = { 3, 7, 11 }; // percentage
table.SetWidths(headerwidths);
table.WidthPercentage = 100; // percenta
table.DefaultCell.BorderWidth = 2;
table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
for (
int i = 0; i < 37; i++)
{
if (i == 15 || i == 30)
{
document.Add(table);
str = System.AppDomain.CurrentDomain.BaseDirectory.ToString() +
"mark.jpg";
Image png = Image.GetInstance(str);
png.SetAbsolutePosition(350f, 498f);
document.Add(png);
document.NewPage();
table = new PdfPTable(3);
table.DefaultCell.Padding = 3;
table.SetWidths(headerwidths);
table.WidthPercentage = 100; // percentage
table.DefaultCell.BorderWidth = 2;
table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
}
phrase2 = new Phrase(paramer[i], FontFactory.GetFont
(FontFactory.TIMES, 10, Font.BOLD, new Color(0, 0, 0)));
phrase1 = new Phrase((i + 1).ToString(), FontFactory.GetFont
(FontFactory.TIMES, 10, Font.BOLD, new Color(0, 0, 0)));
cell = new PdfPCell();
cell.AddElement(phrase1);
table.AddCell(cell);
cell = new PdfPCell();
cell.AddElement(phrase2);
table.AddCell(cell);
str = System.AppDomain.CurrentDomain.BaseDirectory.ToString() +
"grf.jpg";
img = Image.GetInstance(str);
cell = new PdfPCell();
cell.AddElement(img);
table.AddCell(cell);
}
document.Add(table);
document.Close();
please help me to solve this
--
View this message in context: http://www.nabble.com/Placing-Image-over-an-Image-In-a-table-in-a-PDF-Using-Itextsharp-tp18122262p18122262.html
Sent from the itextsharp-questions mailing list archive at Nabble.com.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions
« Return to Thread: Placing Image over an Image In a table in a PDF Using Itextsharp
| Free Forum Powered by Nabble | Forum Help |