2014-11-06 84 views
0

我在动态创建PDF报告,有时内容太长(应该)跨越多个页面。我使用的是段落元素,它只是覆盖它的单元格空间。iText for .NET段落元素重叠自己的文本

Just like here

代码:

'Table SPECS 
Dim tab As New PdfPTable(1) 
tab.TotalWidth = 502.0F 
tab.LockedWidth = True 
tab.SpacingBefore = 140.0F 

Dim phrase As Phrase = Nothing 
Dim cell As New PdfPCell(New Phrase()) 
phrase = New Phrase() 
phrase.Add(New Chunk(dr("Subject").ToString() & vbLf, font)) 
cell = PhraseCell(phrase, PdfPCell.ALIGN_RIGHT) 
cell.VerticalAlignment = PdfCell.ALIGN_TOP 
cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL 
cell.HorizontalAlignment = PdfCell.ALIGN_CENTER 
cell.PaddingLeft = 5.0F 
cell.PaddingBottom = 2.0F 
cell.PaddingTop = 0.0F 
cell.Border = 0 
tab.AddCell(cell) 

Dim p As Paragraph = New Paragraph(dr("Contents"), font) 
p.SpacingBefore = 140.0F 
Dim Col As New ColumnText(writer.DirectContent) 
Col.SetSimpleColumn(50, doc.Bottom + 160, 540, doc.Top - 160) 
Col.RunDirection = PdfWriter.RUN_DIRECTION_RTL 
Col.AddText(p) 
cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL 
cell.PaddingLeft = 5.0F 
cell.PaddingBottom = 2.0F 
cell.PaddingTop = 0.0F 
cell.Border = 0 
Col.Go() 
doc.Add(tab) 
doc.Close() 

我怎样才能正确地实现这一点?

+2

(1)向我们显示您的代码。 (2)你正在使用'leading'的错误值。 (3)如果你显示你的代码,我们可以告诉你你的代码是错误的。 – 2014-11-06 07:31:21

+0

我看到你自己布局文本(使用'new ColumnText(writer.DirectContent)')并且要求iText布置文本(使用'doc.Add(tab)')。你有没有确保你的布局文本没有进入文本iText布局的方式? – mkl 2014-11-06 10:13:38

+0

@mkl其实我只是在最后一次迭代尝试中加入了这一列。在我做之前,它几乎是一样的。 – Nal 2014-11-09 05:56:41

回答