में PdfPCell के लिए चौड़ाई सेट करने के मैं तालिका में PdfpCell के लिए चौड़ाई सेट करना चाहते हैं, मैं चाहता हूँ इसकैसे iTextSharp
मैं लिखें इस कोड
PdfPCell cell;
PdfGrid tableHeader;
PdfGrid tmpTable;
PdfGrid table = new PdfGrid(numColumns: 1) { WidthPercentage = 100, RunDirection = PdfWriter.RUN_DIRECTION_LTR, ExtendLastRow = false };
string imagepath2 = HttpRuntime.AppDomainAppPath + "Header.JPG";
cell = new PdfPCell() { Border = 0, RunDirection = PdfWriter.RUN_DIRECTION_RTL };
cell.Image = iTextSharp.text.Image.GetInstance(imagepath2);
table.AddCell(cell);
tableHeader = new PdfGrid(numColumns: 10);
tableHeader.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
tmpTable = new PdfGrid(numColumns: 1);
tmpTable.TotalWidth = 10f;
tmpTable.LockedWidth = true;
cell = new PdfPCell() {Rotation =-90,VerticalAlignment =Element.ALIGN_MIDDLE, HorizontalAlignment =Element.ALIGN_CENTER, BorderWidth = 1};
cell.Phrase = fontSelector.Process("SER. No");
tmpTable.AddCell(cell);
cell = new PdfPCell(tmpTable) { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
tableHeader.AddCell(cell);
////////////////////////////////////////////////////////////
tmpTable = new PdfGrid(numColumns: 1);
cell = new PdfPCell() { Border = 0, BorderWidthBottom = 1,VerticalAlignment =Element.ALIGN_MIDDLE, HorizontalAlignment =Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("TYPE OF SHIPPING");
//
tmpTable.AddCell(cell);
cell = new PdfPCell() { Border = 0, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("AWB/BL NO.");
tmpTable.AddCell(cell);
cell = new PdfPCell(tmpTable) { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
tableHeader.AddCell(cell);
///////////////////////////////////////////////////////////////
tmpTable = new PdfGrid(numColumns: 1);
cell = new PdfPCell() { Border = 0, BorderWidthBottom = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("ORDER NO.");
tmpTable.AddCell(cell);
cell = new PdfPCell() { Border = 0, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("COMPLEX NAME");
tmpTable.AddCell(cell);
cell = new PdfPCell(tmpTable) { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
tableHeader.AddCell(cell);
///////////////////////////////////////////////////////////////
tmpTable = new PdfGrid(numColumns: 1);
cell = new PdfPCell() { Border = 0, BorderWidthBottom = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("QTY.");
tmpTable.AddCell(cell);
cell = new PdfPCell() { Border = 0, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("G.W Kgs.");
tmpTable.AddCell(cell);
cell = new PdfPCell(tmpTable) { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
tableHeader.AddCell(cell);
///////////////////////////////////////////////////////////////
tmpTable = new PdfGrid(numColumns: 1);
cell = new PdfPCell() { Border = 0, BorderWidthBottom = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("DISCHARGE PPORT");
tmpTable.AddCell(cell);
cell = new PdfPCell() { Border = 0, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("DESTINATON");
tmpTable.AddCell(cell);
cell = new PdfPCell(tmpTable) { BorderWidth = 1 };
tableHeader.AddCell(cell);
///////////////////////////////////////////////////////////////
cell = new PdfPCell() { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("DESCRIPTION OF GOODS");
tableHeader.AddCell(cell);
/////////////////////////////////////////////////////////////
tmpTable = new PdfGrid(numColumns: 1);
cell = new PdfPCell() { Border = 0, BorderWidthBottom = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("LINE DOC. RECI. DATE");
tmpTable.AddCell(cell);
cell = new PdfPCell(new Phrase("")) { Border = 0, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("OWNER DOC. RECI. DATE");
tmpTable.AddCell(cell);
cell = new PdfPCell(tmpTable) { BorderWidth = 1 };
tableHeader.AddCell(cell);
///////////////////////////////////////////////////////////////
cell = new PdfPCell() { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("CLEARANCE DATE");
tableHeader.AddCell(cell);
///////////////////////////////////////////////////////////
cell = new PdfPCell() { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("CUSTOM PERMIT NO.");
tableHeader.AddCell(cell);
///////////////////////////////////////////////////////////
cell = new PdfPCell() { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
cell.Phrase = fontSelector.Process("DISPATCH DATE");
tableHeader.AddCell(cell);
///////////////////////////////////////////////////////////
cell = new PdfPCell(tableHeader) { BorderWidth = 1, VerticalAlignment = Element.ALIGN_MIDDLE, HorizontalAlignment = Element.ALIGN_CENTER };
table.AddCell(cell);
doc.Add(table);
///////////////////////////////////////////////////////////
doc.Close();
लेकिन इस कोड को इस तालिका बनाने के लिए डिजाइन
मैं आकार बदलना चाहता हूं Serno कॉलम लेकिन
लेकिन मुझे नहीं पता कि सेल की चौड़ाई का आकार कैसे बदलें, कृपया मेरी मदद करें।
तुम क्यों PdfGrid प्रयोग करते हैं और PdfPTable नहीं करने के लिए तालिका की शीर्ष दोहराने के लिए प्रयोग किया जाता है? यह स्पष्ट नहीं है कि आप वास्तव में क्या करना चाहते हैं। एक टेबल है तो एक टेबल हैडर और उनके पास कोई लिंक नहीं है। (???) –
@ निक: तालिका शीर्षलेख नेस्टेड टेबल है, इस सेल में केवल रोवनो और मैं चाहता हूं कि मैं छोटा हूं और चौड़ाई – Pouya