间距/引导PdfPCell的元素 [英] Spacing/Leading PdfPCell's elements
问题描述
是否可以在C#中的单元格(行)元素之间添加空格?
我正在visual studio 2012中创建一个pdf,并希望在行之间设置一些空格。我有这样的事情:
Is it possible to add space between the elements of a cell (rows) in C#? I'm creating a pdf in visual studio 2012 and wanted to set some space between the rows. I have something like this:
PdfPTable cellTable = new PdfPTable(1);
PdfPCell cell= new PdfPCell();
for(i=0; i < 5; i++)
{
var titleChunk = new Chunk(tittle[i], body);
var descriptionChunk = new Chunk(" " description[i], body2);
var phrase = new Phrase(titleChunk);
phrase.Add(descriptionChunk);
cell.AddElement(phrase);
}
cellTable.AddCell(cell);
推荐答案
好的,我给你做了一个名为<的例子a href =http://itextpdf.com/sandbox/tables/LeadingInCell =noreferrer> LeadingInCell :
OK, I've made you an example named LeadingInCell:
PdfPCell cell = new PdfPCell();
Paragraph p;
p = new Paragraph(16, "paragraph 1: leading 16");
cell.addElement(p);
p = new Paragraph(32, "paragraph 2: leading 32");
cell.addElement(p);
p = new Paragraph(10, "paragraph 3: leading 10");
cell.addElement(p);
p = new Paragraph(18, "paragraph 4: leading 18");
cell.addElement(p);
p = new Paragraph(40, "paragraph 5: leading 40");
cell.addElement(p);
正如您在 leading_in_cell.pdf ,使用段落
构造函数的第一个参数定义行之间的空格。我使用了不同的值来演示它是如何工作的。第三段坚持第二段,因为第三段的领先只有10磅。第四段和第五段之间有足够的空间,因为第五段的前导是40磅。
As you can see in leading_in_cell.pdf, you define the space between the lines using the first parameter of the Paragraph
constructor. I've used different values to demonstrate how it works. The third paragraph sticks to the second one, because the leading of the third paragraph is only 10 pt. There's plenty of space between the fourth and the fifth paragraph, because the leading of the fifth paragraph is 40 pt.
这篇关于间距/引导PdfPCell的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!