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

void PoDoFo::PdfPainter::DrawTextAligned ( double  dX,
double  dY,
double  dWidth,
const PdfString rsText,
EPdfAlignment  eAlignment 
) [inherited]

Draw a single line of text horizontally aligned.

Parameters:
dXthe x coordinate of the text line
dYthe y coordinate of the text line
dWidththe width of the text line
rsTextthe text to draw
eAlignmentalignment of the text line

Definition at line 982 of file PdfPainter.cpp.

References PoDoFo::PdfPainter::DrawText(), PoDoFo::PdfFont::EmbedFont(), PoDoFo::ePdfError_InvalidHandle, PoDoFo::PdfFont::GetFontMetrics(), PoDoFo::PdfString::IsValid(), PoDoFo::PdfPainter::m_pCanvas, PoDoFo::PdfPainter::m_pFont, PoDoFo::PdfPainter::m_pPage, and PoDoFo::PdfFontMetrics::StringWidth().

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 Septemer 2008
    m_pFont->EmbedFont();

    if( dWidth <= 0.0 ) // nonsense arguments
        return;

    switch( eAlignment ) 
    {
        default:
        case ePdfAlignment_Left:
            break;
        case ePdfAlignment_Center:
            dX += (dWidth - m_pFont->GetFontMetrics()->StringWidth( rsText ) ) / 2.0;
            break;
        case ePdfAlignment_Right:
            dX += (dWidth - m_pFont->GetFontMetrics()->StringWidth( rsText ) );
            break;
    }

    this->DrawText( dX, dY, rsText );
}

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