Pdf 使用IText清除图像对齐

Pdf 使用IText清除图像对齐,pdf,itextsharp,itext,Pdf,Itextsharp,Itext,我在文档中添加图像元素(alignment=left),然后添加一个小段落。一切都很好,但现在我需要添加另一个与图像不对齐的段落(我需要在图像下添加段落,而不是在图像右侧) 例如,在html上,您可以使用样式属性:“clear:both” 语言是VisualBasic,是iText的最后一个版本 _image = iTextSharp.text.Image.GetInstance(myimage) _image.Alignment = iTextSharp.text.Image.ALIG

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

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

语言是VisualBasic,是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"))
你可以看到这个

有人能帮我吗?
感谢大家

一个更好的方法是创建一个
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中。

请发布您尝试的代码以及您正在使用的iText/iTextSharp版本。另外,请参阅此图表,查看XmlWorker中当前支持的CSS属性列表:感谢您提供的提示,这不是我的解决方案,因为有时“text1”很长,我希望始终包装图像,但无论如何,谢谢您。如果在问题中恰当地提到这个问题,我会告诉你答案的。不管怎样,明天检查我的编辑,因为我的代码在办公室。@Saksham你说你会发布什么更好的解决方案?我在这里看不到。@Saksham你对此有过答案吗?@jpo这是很久以前的答案,可能那是我最后一次使用iTextSharp。之后我换了两家公司,我的技术也一样。对不起,我没有答案。将删除我的评论