C
C#14mo ago
PontiacGTX

❔ itextsharp not rendering cells for a table

I am trying to display a cell in iTextSharp Version in a second page but it does not display the cells for some reason here is the code
float dpi = 100f;
float widthInches = (3900f * 1.1f) / dpi;
float heightInches = (2775f * 1.1f) / dpi;

// Increase the size of the Rectangle object by 10%
float width = widthInches * 1.1f * 72f;
float height = heightInches * 1.1f * 72f;

var pageSize = new iTextSharp.text.Rectangle(width, height);
var rect = new iTextSharp.text.Rectangle(width, height);

iTextSharp.text.Document document = new iTextSharp.text.Document(rect, 10f, 10f, 10f, 0f);
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream(dest, System.IO.FileMode.Create));
document.Open();

document.NewPage();
iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(model.CaraB["1"]);
image.SetAbsolutePosition(0, 0);
image.ScaleToFit(3400, 2400);
document.Add(image1);

PdfPTable table = new PdfPTable(2);
var cell = new PdfPCell(new iTextSharp.text.Phrase("Logros"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;

table.AddCell(cell);
table.AddCell("Logros");
table.AddCell("Horas");
document.Add(table);
float dpi = 100f;
float widthInches = (3900f * 1.1f) / dpi;
float heightInches = (2775f * 1.1f) / dpi;

// Increase the size of the Rectangle object by 10%
float width = widthInches * 1.1f * 72f;
float height = heightInches * 1.1f * 72f;

var pageSize = new iTextSharp.text.Rectangle(width, height);
var rect = new iTextSharp.text.Rectangle(width, height);

iTextSharp.text.Document document = new iTextSharp.text.Document(rect, 10f, 10f, 10f, 0f);
iTextSharp.text.pdf.PdfWriter writer = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream(dest, System.IO.FileMode.Create));
document.Open();

document.NewPage();
iTextSharp.text.Image image1 = iTextSharp.text.Image.GetInstance(model.CaraB["1"]);
image.SetAbsolutePosition(0, 0);
image.ScaleToFit(3400, 2400);
document.Add(image1);

PdfPTable table = new PdfPTable(2);
var cell = new PdfPCell(new iTextSharp.text.Phrase("Logros"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;

table.AddCell(cell);
table.AddCell("Logros");
table.AddCell("Horas");
document.Add(table);
the output is the following: https://i.stack.imgur.com/ni8WA.png
2 Replies
PontiacGTX
PontiacGTX14mo ago
Stack Overflow
Paramgraph is not being written on top of an image in Itextsharp
I am trying to set this table on top of an image for this PDF document but It moves the table and the paragraph overall on the next page... document.NewPage(); iTextSharp.text.
Accord
Accord14mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.