使用iTextSharp我正在尝试对齐图像,使其嵌入段落中。我可以这样做:
iTextSharp.text.Image image;
image.Alignment = Image.ALIGN_RIGHT | Image.TEXTWRAP;
document.Add(image);
document.Add(new Paragraph("Large string of text goes here"));
但是图像出现在右上方,周围有文字(有点像L)
我想要的是文本是几段然后是带有文本的图像(有点像C)。有谁知道我会怎么做这个VIA iTextSharp?
编辑:
我也试过
iTextSharp.text.Image image;
image.Alignment = Image.ALIGN_RIGHT | Image.TEXTWRAP | Image.ALIGN_MIDDLE;
document.Add(image);
document.Add(new Paragraph("Large string of text goes here"));
但它显示的是顶部的图像和下面的文字。没有文字包裹生效。
答案 0 :(得分:14)
短语和段落对象的行为方式不同。尝试更改为:
image.Alignment = 6;
document.Add(image);
document.Add(new Phrase("Large string of text goes here"));
这在VB中对我有用。 (我不得不将图像对齐方式更改为ALIGN_RIGHT和TEXTWRAP的整数值之和,以使其正常工作)。
ALIGN_RIGHT = 2
TEXTWRAP = 4
您的图片显示在页面顶部,因为它是第一个添加到文档中的内容,并在其后添加了文本。 您可以通过设置其绝对位置或向文档中添加一些文本,然后添加图像,然后添加其余文本来向下移动图像。