Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] Word breaks and Tagged PDF content

David Powell

2007-07-12



I am creating a tagged PDF document using the iText 2.0 tagging features.
First I begin a marked-content-sequence then loop thru a list of words and
add each word to the PdfContentByte at a fixed coordinate position. I am
adding all the words within a paragraph tag container <P>. The problem is
all the words are added within the tag <P> as one continuos string without
any spacing (word breaks) between words, even though the coordinates of the
words provide for such spacing. How do i include word breaks (as mentioned
in the PDF specs sect 10.7) in such scenario ? Am I even approaching this
issue the correct way ?

Please see my code sample below:

writer.setTagged();
PdfContentByte cb = writer.getDirectContent();
PdfStructureTreeRoot root = writer.getStructureTreeRoot();
PdfStructureElement para = new PdfStructureElement(root, PdfName.P);

cb.beginMarkedContentSequence(para);

for(Word word : listOfWords){
    cb.beginText();
    cb.setColorFill(Color.RED);          
    cb.setFontAndSize(baseFont, word.getFontSize());
    cb.setTextMatrix(word.getLeft(),word.getBottom());
    cb.showText(word.getText());
    cb.endText();
}
cb.endMarkedContentSequence();



--
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
©2008 junlu.com - Jax Systems, LLC, U.S.A.