Index: PdfPainter.cpp
===================================================================
--- PdfPainter.cpp	(revision 1857)
+++ PdfPainter.cpp	(working copy)
@@ -923,7 +923,7 @@
 }
 
 void PdfPainter::DrawMultiLineText( double dX, double dY, double dWidth, double dHeight, const PdfString & rsText, 
-                                    EPdfAlignment eAlignment, EPdfVerticalAlignment eVertical, bool bClip )
+                                    EPdfAlignment eAlignment, EPdfVerticalAlignment eVertical, bool bClip,bool bSkipSpaces )
 {
     PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
 
@@ -946,7 +946,7 @@
 
     PdfString   sString  = this->ExpandTabs( rsText, rsText.GetCharacterLength() );
 
-	std::vector<PdfString> vecLines = GetMultiLineTextAsLines(dWidth, sString);
+	std::vector<PdfString> vecLines = GetMultiLineTextAsLines(dWidth, sString,bSkipSpaces);
     double dLineGap = m_pFont->GetFontMetrics()->GetLineSpacing() - m_pFont->GetFontMetrics()->GetAscent() + m_pFont->GetFontMetrics()->GetDescent();
     // Do vertical alignment
     switch( eVertical ) 
@@ -975,7 +975,7 @@
     this->Restore();
 }
 
-std::vector<PdfString> PdfPainter::GetMultiLineTextAsLines( double dWidth, const PdfString & rsText)
+std::vector<PdfString> PdfPainter::GetMultiLineTextAsLines( double dWidth, const PdfString & rsText, bool bSkipSpaces)
 {
     PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
 
@@ -1032,11 +1032,18 @@
                 else
                 {
                     vecLines.push_back( PdfString( pszLineBegin, pszCurrentCharacter - pszLineBegin ) );
-                    // Skip all spaces at the end of the line
-                    while (IsSpaceChar(*(pszCurrentCharacter + 1)))
-                        pszCurrentCharacter++;
+                    if (bSkipSpaces)
+                    {
+                        // Skip all spaces at the end of the line
+                        while (IsSpaceChar(*(pszCurrentCharacter + 1)))
+                            pszCurrentCharacter++;
 
-                    pszStartOfCurrentWord = pszCurrentCharacter + 1;
+                        pszStartOfCurrentWord = pszCurrentCharacter + 1;
+                    }
+                    else
+                    {
+                        pszStartOfCurrentWord = pszCurrentCharacter;
+                    }
                     startOfWord=true;
                 }
                 pszLineBegin = pszStartOfCurrentWord;
@@ -1051,6 +1058,25 @@
                     dCurWidthOfLine = 0.0;
                 }
             }
+            else if ((dCurWidthOfLine + m_pFont->GetFontMetrics()->UnicodeCharWidth(SwapCharBytesIfRequired(*pszCurrentCharacter))) > dWidth)
+            {
+                vecLines.push_back(PdfString(pszLineBegin, pszCurrentCharacter - pszLineBegin));
+                if (bSkipSpaces)
+                {
+                    //skip the spaces appearing at the end of line
+                    while (IsSpaceChar(*(pszCurrentCharacter + 1)))
+                        pszCurrentCharacter++;
+
+                    pszStartOfCurrentWord = pszCurrentCharacter + 1;
+                }
+                else
+                {
+                    pszStartOfCurrentWord = pszCurrentCharacter;
+                }
+                pszLineBegin = pszStartOfCurrentWord;
+                startOfWord = true;
+                dCurWidthOfLine = 0.0;
+            }
             else 
             {           
                 dCurWidthOfLine += m_pFont->GetFontMetrics()->UnicodeCharWidth( SwapCharBytesIfRequired( *pszCurrentCharacter ) );
Index: PdfPainter.h
===================================================================
--- PdfPainter.h	(revision 1857)
+++ PdfPainter.h	(working copy)
@@ -406,10 +406,11 @@
      *  \param eAlignment alignment of the individual text lines in the given bounding box
      *  \param eVertical vertical alignment of the text in the given bounding box
      *  \param bClip set the clipping rectangle to the given rRect, otherwise no clipping is performed
+     *  \param bSkipSpaces if the trailing whitesaces should be skipped, so that next line doesn't start with whitespace
      */
     void DrawMultiLineText( double dX, double dY, double dWidth, double dHeight, 
                             const PdfString & rsText, EPdfAlignment eAlignment = ePdfAlignment_Left,
-                            EPdfVerticalAlignment eVertical = ePdfVerticalAlignment_Top, bool bClip = true );
+                            EPdfVerticalAlignment eVertical = ePdfVerticalAlignment_Top, bool bClip = true,bool bSkipSpaces = true);
 
     /** Draw multiline text into a rectangle doing automatic wordwrapping.
      *  The current font is used and SetFont has to be called at least once
@@ -420,16 +421,18 @@
      *  \param eAlignment alignment of the individual text lines in the given bounding box
      *  \param eVertical vertical alignment of the text in the given bounding box
      *  \param bClip set the clipping rectangle to the given rRect, otherwise no clipping is performed
+     *  \param bSkipSpaces if the trailing whitesaces should be skipped, so that next line doesn't start with whitespace
      */
     inline void DrawMultiLineText( const PdfRect & rRect, const PdfString & rsText, EPdfAlignment eAlignment = ePdfAlignment_Left,
-                                   EPdfVerticalAlignment eVertical = ePdfVerticalAlignment_Top, bool bClip = true );
+                                   EPdfVerticalAlignment eVertical = ePdfVerticalAlignment_Top, bool bClip = true,bool bSkipSpaces = true);
 
     /** Gets the text divided into individual lines, using the current font and clipping rectangle.
      *
      *  \param dWidth width of the text area
      *  \param rsText the text which should be drawn
+     *  \param bSkipSpaces if the trailing whitesaces should be skipped, so that next line doesn't start with whitespace
      */
-    std::vector<PdfString> GetMultiLineTextAsLines( double dWidth, const PdfString & rsText);
+    std::vector<PdfString> GetMultiLineTextAsLines( double dWidth, const PdfString & rsText, bool bSkipSpaces=true);
 
     /** Draw a single line of text horizontally aligned.
      *  \param dX the x coordinate of the text line
@@ -966,10 +969,10 @@
 // 
 // -----------------------------------------------------
 void PdfPainter::DrawMultiLineText( const PdfRect & rRect, const PdfString & rsText, 
-                                    EPdfAlignment eAlignment, EPdfVerticalAlignment eVertical, bool bClip)
+                                    EPdfAlignment eAlignment, EPdfVerticalAlignment eVertical, bool bClip,bool bSkipSpaces)
 {
     this->DrawMultiLineText( rRect.GetLeft(), rRect.GetBottom(), rRect.GetWidth(), rRect.GetHeight(), 
-                             rsText, eAlignment, eVertical, bClip );
+                             rsText, eAlignment, eVertical, bClip, bSkipSpaces );
 }
 
 };
