0

我在文档中添加图像元素(对齐 = 左),然后添加一小段。一切正常,但现在我需要添加另一个与图像不对齐的段落(我需要在图像下方而不是图像右侧添加段落)

例如,在 html 上,您可以使用样式属性:“clear:both”。

语言是 Visual Basic 和 iText 的最后一个版本

_image = iTextSharp.text.Image.GetInstance(myimage)    
_image.Alignment = iTextSharp.text.Image.ALIGN_LEFT + iTextSharp.text.Image.TEXTWRAP
_document.add(_image)
_document.add(New Paragraph("This text will be show on the right of the image"))
_document.add(New Paragraph("Also this text will be show on the right of the image but I want the text on the bottom of the image"))

你可以看到这个http://www.pasteall.org/pic/show.php?id=53656

有人可以帮助我吗?感谢大家

4

1 回答 1

0

更好的方法是创建一个PdfPTable并在其中添加单元格。在第一行添加 2 个单元格,为第二行添加colspan = 2. 这是示例代码。

PdfPTable table = new PdfPTable(2); //table with 2 columns
PdfPCell cell1 = new PdfPCell(_Image);
PdfPCell cell2 = new PdfPCell(new Phrase("Your text1"));
PdfPCell cell3 = new PdfPCell(new Phrase("Your text2"));
cell3.Colspan = 2;
Table.AddCell(cell1);
Table.AddCell(cell2);
Table.AddCell(cell3);
_document.Add(table);

注意: *总是尝试将您的内容包含在 PDF 的表格中,因为它会生成结构化的 PDF。

于 2013-06-19T08:29:10.440 回答