C# itextsharp中的文本正确格式和对齐方式
我使用这段代码将表中的两个短语/两列对齐在一起C# itextsharp中的文本正确格式和对齐方式,c#,css,itextsharp,phrase,C#,Css,Itextsharp,Phrase,我使用这段代码将表中的两个短语/两列对齐在一起 table = new PdfPTable(2); table.TotalWidth = 450f; table.LockedWidth = true; float[] widths= new float[] { 100f, 350f }; table.SetWidths(widths); table.WidthPercentage = 85;
table = new PdfPTable(2);
table.TotalWidth = 450f;
table.LockedWidth = true;
float[] widths= new float[] { 100f, 350f };
table.SetWidths(widths);
table.WidthPercentage = 85;
table.HorizontalAlignment = Element.ALIGN_LEFT;
cell = new PdfPCell();
cell = PhraseCell(new Phrase("Repair 2 - Tongue pig biltong picanha:", newfntbld), PdfPCell.ALIGN_LEFT);
cell.PaddingTop = 12f;
table.AddCell(cell);
cell = PhraseCell(new Phrase("Ham beef ball tip, pastrami sausage ribeye meatloaf salami kielbasa. Ground round bresaola pastrami ham capicola pork belly, tri-tip drumstick. Beef hamburger pork loin bacon doner chuck shank strip steak ham hock meatloaf. Flank meatball swine frankfurter.", newlightfnt), PdfPCell.ALIGN_LEFT);
cell.PaddingTop = 12f;
cell.Border = 0;
table.AddCell(cell);
我得到了这个结果
但我想这样表现:
表格通常不会提供这种布局。你为什么要把这个塞进桌子里 将其构建为一个段落要容易得多:
Phrase phrase1 = new Phrase("Repair 2 - Tongue pig biltong picanha - ", newfntbld);
Phrase phrase2 = new Phrase("Ham beef ball tip, pastrami sausage ribeye meatloaf salami kielbasa. Ground round bresaola pastrami ham capicola pork belly, tri-tip drumstick. Beef hamburger pork loin bacon doner chuck shank strip steak ham hock meatloaf. Flank meatball swine frankfurter.", newlightfnt);
Paragraph para = new Paragraph();
para.Add(phrase1);
para.Add(phrase2);
我不知道如何使用段落或短语…这就是为什么我使用表格…thnks来共享此代码…我只寻找此类代码。。。