gpt4 book ai didi

c# - itextsharp 中的文本正确格式和对齐方式

转载 作者:行者123 更新时间:2023-11-28 16:08:50 31 4
gpt4 key购买 nike

我正在使用此代码将表格中的两个短语/两列对齐

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

我得到这个作为结果 enter image description here

但我想这样显示:

enter image description here

最佳答案

表格通常不会为您提供那种布局。你为什么要把它塞进 table 里?

将其构建为一个段落要容易得多:

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

关于c# - itextsharp 中的文本正确格式和对齐方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33234254/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com