Christian Hauser wrote:

I need to place text boxes within a PDF file like this:

   ---------------------
   | Here some text... |
   ---------------------

These text boxes might have a border (top, bottom, right and left part of the border might have a different width), a border color, a text color, a background color and of course can be placed at an absolute position.

What would be the best way to draw such text boxes? By using a table with only one cell? Or by painting 4 lines, a spotcolor (for the background) and some text above it? The problem is that the text should not become larger than the box.

What is more important to you, the width of the box or the width of the text?


With PdfPTable, you will define the width of the table and add text to a cell.
The text will be wrapped and the height of your box will increase.
If you don't want the text to wrap (but everything on a single line), you will
have to measure the text and draw a rectangle based on the results.
( http://itext.sourceforge.net/tutorial/fonts/styles/index.html#measuring
and http://itext.sourceforge.net/tutorial/directcontent/graphics/index.html#paths )
Using a Chunk with a generic page event would be easiest way to achieve this
(http://itext.sourceforge.net/tutorial/objects/chunk/index.html#generic), but I
don't recall a method that allows you to add a Chunk at absolute positions
(Or you would have to use ColumnText, but then again you need to define
the width of the column in advance).


br,
Bruno


------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to