Logo Search packages:      
Sourcecode: libpodofo version File versions  Download package

void PoDoFo::PdfPainter::DrawMultiLineText ( double  dX,
double  dY,
double  dWidth,
double  dHeight,
const PdfString rsText,
EPdfAlignment  eAlignment = ePdfAlignment_Left,
EPdfVerticalAlignment  eVertical = ePdfVerticalAlignment_Top 
) [inherited]

Draw multiline text into a rectangle doing automatic wordwrapping. The current font is used and SetFont has to be called at least once before using this function

Parameters:
dXthe x coordinate of the text area (left)
dYthe y coordinate of the text area (bottom)
dWidthwidth of the text area
dHeightheight of the text area
rsTextthe text which should be drawn
eAlignmentalignment of the individual text lines in the given bounding box
eVerticalvertical alignment of the text in the given bounding box

Definition at line 797 of file PdfPainter.cpp.

References PoDoFo::PdfPainter::DrawTextAligned(), PoDoFo::PdfFont::EmbedFont(), PoDoFo::ePdfError_InvalidHandle, PoDoFo::PdfPainter::ExpandTabs(), PoDoFo::PdfString::GetCharacterLength(), PoDoFo::PdfFont::GetFontMetrics(), PoDoFo::PdfFontMetrics::GetLineSpacing(), PoDoFo::PdfPainter::GetMultiLineTextAsLines(), PoDoFo::PdfString::IsValid(), PoDoFo::PdfPainter::m_pCanvas, PoDoFo::PdfPainter::m_pFont, PoDoFo::PdfPainter::m_pPage, PoDoFo::PdfPainter::Restore(), PoDoFo::PdfPainter::Save(), and PoDoFo::PdfPainter::SetClipRect().

Referenced by PoDoFo::PdfTable::Draw(), and PoDoFo::PdfPainter::DrawMultiLineText().

{
    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );

    if( !m_pFont || !m_pPage || !rsText.IsValid() )
    {
        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
    }

    // Peter Petrov 25 September 2008
    m_pFont->EmbedFont();
    
    if( dWidth <= 0.0 || dHeight <= 0.0 ) // nonsense arguments
        return;

    this->Save();
    this->SetClipRect( dX, dY, dWidth, dHeight );

    PdfString   sString  = this->ExpandTabs( rsText, rsText.GetCharacterLength() );

    std::vector<TLineElement> vecLines = GetMultiLineTextAsLines(dWidth, sString);

    // Do vertical alignment
    switch( eVertical ) 
    {
        default:
        case ePdfVerticalAlignment_Top:
            dY += dHeight; break;
        case ePdfVerticalAlignment_Bottom:
            dY += m_pFont->GetFontMetrics()->GetLineSpacing() * vecLines.size(); break;
        case ePdfVerticalAlignment_Center:
            dY += (dHeight - 
                   ((dHeight - (m_pFont->GetFontMetrics()->GetLineSpacing() * vecLines.size()))/2.0)); 
            break;
    }

    std::vector<TLineElement>::const_iterator it = vecLines.begin();
    while( it != vecLines.end() )
    {
        dY -= m_pFont->GetFontMetrics()->GetLineSpacing();
        if( (*it).pszStart )
            this->DrawTextAligned( dX, dY, dWidth, PdfString( (*it).pszStart, (*it).lLen ), eAlignment );

        ++it;
    }
    this->Restore();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index