问题
I am using iText to generate my custom .pdf document. I tried a lot but i am not able to do get a desired design of my text which includes an image. I need an output just like shown below:
I have tried Chunk class and Paragraph class but i am not able to get the desired. Any ideas?
回答1:
You have (at least) two options:
- Use
image.setAlignment(Image.LEFT | Image.TEXTWRAP);and add the image to the document (not to aChunkorParagraph). This will add the image to the left and wrap the other text around it. - Add the image at an absolute position, and add the text using
ColumnTextfor irregular columns: http://1t3xt.be/?0b3
1 is the easiest way, but the result may not always be what you desire (you can tweak some things, such as adding a borden); 2 demands more work, but allows you to create the output exactly the way you want to.
来源:https://stackoverflow.com/questions/13030250/image-in-between-a-paragraph-using-itext