There’s no general table-construction code in PDFBox. You need to
implement your own business logic for working out the geometry of where
your text and stuff will go. So you need to know the bounds of your area,
how much vertical space each cell requires, etc.

Unfortunately the code I wrote to do this was for a client so I can’t
share it, but basically I set up an object to hold the geometric aspects
and a helper class to maintain the current position on the page with some
helper methods to update the position as needed, e.g., to move down one
row or move to the second column, as well as logic to determine when the
page was full.

Here’s my method for actually writing text:

 public static void placeText(PDPageContentStream contentStream,
                        float yPos, 
                        float xPos, 
                        String text) throws IOException {
                contentStream.beginText();
                contentStream.moveTextPositionByAmount( xPos, yPos );   
                contentStream.drawString(text);                 
                contentStream.endText();
        }



And here’s a typical use:

   yPosition -= lineHeight;
                        PDFHelper.placeText(
                                        contentStream,
                                        yPosition, 
                                        leftMargin, 
textValue);

                        contentStream.setFont( fontHelvNormal, 
HEADER_TEXT_FONT_SIZE );
                        yPosition -= (lineHeight * 2);
                        PDFHelper.placeText(
                                        contentStream,
                                        yPosition, 
                                        leftMargin, 
textValue);

Cheers,


Eliot

-- 
Eliot Kimber
Senior Solutions Architect
"Bringing Strategy, Content, and Technology Together"
Main: 512.554.9368
www.reallysi.com
www.rsuitecms.com




On 11/13/13, 9:11 AM, "Rick R" <[email protected]> wrote:

>I need to create my pdf dynamically, iterating over different  types of
>java objects etc.. and all I'll be putting data into two columns ..
>basically a label column and then a value column. I need the value column
>to wrap though.
>
>I don't see any sort of table like functionality built in?
>
>(The docs really do not have much information so I'm starting to ask
>here.)
>
>-- 
>Rick R

Reply via email to