Hi,

I do not have such a function at hand. But it might be a nice addition for 
PdfPainter for users who need quick multiline text output with no 
WYSISYG-needs.

You are right. You can easily implement such a function your self using 
PdfFont::GetFontMetrics()->StringWidth().

A nice example can be found in the CreateTest test included in PoDoFo:

<snip>
    pFont = pDocument->CreateFont( "Arial" );
    if( !pFont )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    pFont->SetFontSize( 16.0 );

    const char* msg = "Grayscale - Colorspace";
    h = pFont->GetFontMetrics()->GetLineSpacing();
    w = pFont->GetFontMetrics()->StringWidth( msg );

    pPainter->SetFont( pFont );
    // Draw the text on the page
    pPainter->DrawText( x, y - pFont->GetFontMetrics()->GetLineSpacing(), 
msg );
    // Draw a box around the text
    pPainter->DrawRect( x, y, w, h );
</snap>

This example draw the text "Grayscale - Colorspace" to a page and draws a box 
exactly around the text. The values used to draw the box are the ones you 
need to calculate wordwrapping information.

Hope this helps.

best regards,
        Dom

Am Thursday 06 September 2007 schrieb Ian Curington:
> Hi, I'm looking for a simple class using PoDoFo services that will draw
> a multi-line text string into a rectangular box with text wrapping,
> assuming the current font settings. Does anyone have such a function or
> class, along the lines the following?
>
> DrawMultilineText (     int     left,
>                 int     bottom,
>                 int     width,
>                 int     height,
>                 const String &  text,
>                 int     alignment,
>                 bool    wordWrap = true  )
>
> or failing that, something that will give an estimate if height & length
> in PDF units of the string so I can implement some sort of simple wrap
> and line spacing? It looks like it may be possible by using:
>
> PoDoFo:PdfFont::GetFontMetrics()
>    PdfFontMetrics::StringWidth()
>
> but I'm not sure.
>
> Thanks!



-- 
**********************************************************************
Dominik Seichter - [EMAIL PROTECTED]
KRename  - http://www.krename.net  - Powerful batch renamer for KDE
KBarcode - http://www.kbarcode.net - Barcode and label printing
PoDoFo - http://podofo.sf.net - PDF generation and parsing library
SchafKopf - http://schafkopf.berlios.de - Schafkopf, a card game,  for KDE
Alan - http://alan.sf.net - A Turing Machine in Java
**********************************************************************

Attachment: pgpWhmwsyEFzG.pgp
Description: PGP signature

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to