A followup question...
I am using ColumnText as you suggested and checked the result of the
call to go().
If the result is NO_COLUMN_LEFT, I reduce the font size of the Chunk and
try again until I get NO_TEXT_LEFT.
Here is the idea (newSimpleColumn wraps a call to setSimpleColumn
setting the location/size of the col)...
Chunk contentChunk;
ColumnText colTxt;
while(colResult == ColumnText.NO_MORE_COLUMN && font.size() >=
MIN_FONT_SIZE) {
colTxt = new ColumnText(cb);
colTxt = newSimpleColumn(...);
colTxt.addText(contentChunk);
colResult = colTxt.go(true);
if(colResult == ColumnText.NO_MORE_COLUMN) {
font.setSize(font.size()-0.25f);
} else {
colTxt = new ColumnText(cb);
colTxt = newSimpleColumn(...);
colTxt.addText(contentChunk);
colResult = colTxt.go();
log.debug("GO REAL = " + colResult);
}
}
Here's the problem I'm running into - as you can see there's a bunch of
duplication in that code where I create a new ColumnText object each
time. I tried using a single ColumnText object initialized before the
loop and calling clearChunks() then addText(contentChunk), however, that
did not work - I ended up with no text appearing in my PDF file after
the colTxt.go() call. Any ideas about what could be going on under the
iText hood or with the way I'm using iText to cause this behavior?
Here's the code I can't get to work...
Chunk contentChunk;
ColumnText colTxt = new ColumnText(cb);
colTxt = newSimpleColumn(...);
while(colResult == ColumnText.NO_MORE_COLUMN && font.size() >=
MIN_FONT_SIZE) {
colTxt.clearChunks();
colTxt.addText(contentChunk);
colResult = colTxt.go(true);
if(colResult == ColumnText.NO_MORE_COLUMN) {
font.setSize(font.size()-0.25f);
} else {
colResult = colTxt.go();
log.debug("GO REAL = " + colResult);
}
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Paulo
Soares
Sent: Friday, 05 December, 2003 06:09
To: Andy Kriger; [EMAIL PROTECTED]
Subject: RE: [iText-questions] automatic font sizing and wrapping?
-----Original Message-----
From: [EMAIL PROTECTED]
[SMTP:[EMAIL PROTECTED] On Behalf Of Andy
Kriger
Sent: Thursday, December 04, 2003 20:30
To: [EMAIL PROTECTED]
Subject: [iText-questions] automatic font sizing and wrapping?
We have a system that currently uses FDF files to create dynamic PDFs
using a form template. There are fields defined in the template and data
is associated with each field. A field can be marked as multiline and a
field's font size can be 'Auto' (the font size is reduced to fit all the
text within the field).
Since there the FDF system has limitations, we are moving to iText and
creating the PDFs programmatically. Is there similar font
wrapping/sizing behavior built into iText?
I want to give:
* the X/Y location
* the width/height of a rectangle
* the text string (or bytes)
No problem. That's what ColumnText does.
And do:
* draw text into that area
Ok.
* have the text automatically wrap
Ok.
* have the text scale to fit the space
There's code to do this in TextField.java. Adapt it for your needs.
Best Regards,
Paulo Soares
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions