文字中的图像对齐? [英] Image alignment in text?

查看:124
本文介绍了文字中的图像对齐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用iTextSharp我正在尝试对齐图像,使其嵌入段落中。我可以这样做:

Using iTextSharp i'm trying to align an image so that it gets embedded in a paragraph. I can do it like this:

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)

But the image comes out on the top right with the text surrounding it (kind of like an L)

我想要的是文本是几段然后是带有文本的图像(有点像C)。有谁知道我会怎么做这个VIA iTextSharp?

What I want is the text to be a few paragraphs then the image with text below it (kind of like a C). Does anyone know how I would do this 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"));

但它显示的是顶部的图像和下面的文字。没有有效的textwrap。

But it was displayed with the image at the top and the text below it. There was no textwrap in effect.

推荐答案

Phrase和Paragraph对象的行为方式不同。尝试更改为:

The Phrase and the Paragraph objects do behave differently. Try changing to:

image.Alignment = 6;
document.Add(image);
document.Add(new Phrase("Large string of text goes here"));

这在VB中对我有用。 (我不得不将图像对齐更改为ALIGN_RIGHT和TEXTWRAP的整数值之和,以使其正常工作)。

This worked for me in VB. ( I had to change the image alignment to the sum of the integer values for ALIGN_RIGHT and TEXTWRAP to get this to work properly).

ALIGN_RIGHT = 2
TEXTWRAP = 4

您的图片显示在页面顶部因为它是第一个添加到文档中的内容,文本是在它之后添加的。
您可以通过设置其绝对位置或向文档中添加一些文本,然后添加图像,然后添加其余文本来向下移动图像。

Your image was displayed at the top of the page because it was the first thing added to the document, and the text was added after it. You can move the image down by either setting its absolute position, or by adding some of your text to the document, then adding the image, then adding the rest of your text.

这篇关于文字中的图像对齐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆