C# iTextSharp绝对定位(GridView)
我在使用iTextSharp重叠桌子时遇到问题 我有多个表(来自GridView),我想使用iTextSharp将其写入pdf 我只希望每个桌子之间有10px的间隙(垂直方向),并且桌子的高度总是不同的C# iTextSharp绝对定位(GridView),c#,.net,itextsharp,C#,.net,Itextsharp,我在使用iTextSharp重叠桌子时遇到问题 我有多个表(来自GridView),我想使用iTextSharp将其写入pdf 我只希望每个桌子之间有10px的间隙(垂直方向),并且桌子的高度总是不同的 有没有人能给我读一篇文章来帮助我解决这个问题?或者有什么建议?绝对定位对我不起作用。您可以将每个表放在iTextSharp.text.paragration中,并使用paragration对象的SpacingAfter属性创建间距 与此试验方法类似: private static void De
有没有人能给我读一篇文章来帮助我解决这个问题?或者有什么建议?绝对定位对我不起作用。您可以将每个表放在
iTextSharp.text.paragration
中,并使用paragration
对象的SpacingAfter
属性创建间距
与此试验方法类似:
private static void DemoTableSpacing() {
using (FileStream fs = new FileStream("SpacingTest.pdf", FileMode.Create)) {
Document doc = new Document();
PdfWriter.GetInstance(doc, fs);
doc.Open();
Paragraph paragraphTable1 = new Paragraph();
paragraphTable1.SpacingAfter = 15f;
PdfPTable table = new PdfPTable(3);
PdfPCell cell = new PdfPCell(new Phrase("This is table 1"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
//table.AddCell("Col 1 Row 2");
//table.AddCell("Col 2 Row 2");
//table.AddCell("Col 3 Row 2");
paragraphTable1.Add(table);
doc.Add(paragraphTable1);
Paragraph paragraphTable2 = new Paragraph();
paragraphTable2.SpacingAfter = 10f;
table = new PdfPTable(3);
cell = new PdfPCell(new Phrase("This is table 2"));
cell.Colspan = 3;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
table.AddCell("Col 1 Row 1");
table.AddCell("Col 2 Row 1");
table.AddCell("Col 3 Row 1");
table.AddCell("Col 1 Row 2");
table.AddCell("Col 2 Row 2");
table.AddCell("Col 3 Row 2");
paragraphTable2.Add(table);
doc.Add(paragraphTable2);
doc.Close();
}
}
这应该表明你能做什么。尝试在第一个表中添加和删除行;您将看到两个表之间的空间始终存在,并且不会改变