So legen Sie die Breite für PdfPCell in ItextSharp fest

Ich möchte die Breite für PdfpCell in Tabelle festlegen, ich möchte dies entwerfen


i Schreiben Sie diesen Code

  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();

aber dieser Code erstellt diese Tabelle

Ich möchte die Breite der Spalte "SerNo" ändern, aber

Aber ich weiß nicht, wie ich die Breite der Zelle ändern soll, bitte helfen Sie mir.

Antworten auf die Frage(4)

Ihre Antwort auf die Frage