Jeff Kelm wrote:
> Hi,
>
> com.lowagie.text.Phrase#add(Object) invokes
> com.lowagie.text.Phrase#addChunk(Chunk) when adding a Chunk. addChunk()
> sets a com.lowagie.text.Chunk.HYPHENATION attribute to the Chunk being
> added if the Chunk was missing this attribute. As one of its conditions
> for returning 'true', com.lowagie.text.Chunk#isEmpty() specifies that
> its 'attributes' field be null. An 'empty' Chunk (as defined by
> com.lowagie.text.Chunk#isEmpty()) added to a Phrase (or one of its
> subclasses) will no longer have a null attributes field, so will no
> longer be 'empty'.
>
> I came across this problem when running a
> com.lowagie.text.Paragraph#isEmpty() on a Paragraph to which an 'empty'
> Chunk had been added. Paragraph#isEmpty() returned false because the
> formerly 'empty' Chunk was being evaluated as 'not empty' because of the
> addition of the HYPHENATION attribute.
>
> Thoughts?
Would this change solve the problem?
Modified: trunk/src/core/com/lowagie/text/Phrase.java
===================================================================
--- trunk/src/core/com/lowagie/text/Phrase.java 2009-05-27 13:09:45 UTC
(rev 3939)
+++ trunk/src/core/com/lowagie/text/Phrase.java 2009-05-28 14:28:39 UTC
(rev 3940)
@@ -400,7 +400,7 @@
}
Chunk newChunk = new Chunk(c, f);
newChunk.setAttributes(chunk.getAttributes());
- if (newChunk.getHyphenation() == null) {
+ if (hyphenation != null && newChunk.getHyphenation() == null &&
!newChunk.isEmpty()) {
newChunk.setHyphenation(hyphenation);
}
return super.add(newChunk);
best regards,
Bruno
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/