Hi Dominik, hi all
Thanks for committing the fix.
I see that the same problem exists for bottom and center alignments too. The
text is placed lower than they should be.
Currently for bottom alignment, the lowest text would be at the border with no
gap.
So I suggest reverting the previous fix for the following general fix
Keep the following part as follows reverting the previous fix
default:
case ePdfVerticalAlignment_Top:
dY += dHeight; break;
and replace the corresponding part(to the following snippet) with
while( it != vecLines.end() )
{
if( (*it).GetCharacterLength() )
this->DrawTextAligned(dX, dY -
m_pFont->GetFontMetrics()->GetAscent(), dWidth, *it, eAlignment);
dY -= m_pFont->GetFontMetrics()->GetLineSpacing();
++it;
}
Regards
Jaseem
From: Jaseem Ali K T
Sent: 13 May 2016 16:37
To: podofo-users@lists.sourceforge.net
Subject: Issue with DrawMultiLineText()
Hi all
I would like to point out a small bug in DrawMultiLineText() function of
PdfPainter class.
Below is the relevant code portion as per latest revision
// 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<PdfString>::const_iterator it = vecLines.begin();
while( it != vecLines.end() )
{
dY -= m_pFont->GetFontMetrics()->GetLineSpacing();
if( (*it).GetCharacterLength() )
this->DrawTextAligned( dX, dY, dWidth, *it, eAlignment );
++it;
}
..
So for Top Alignment (as per the current code) the first alignment will start
at (dHeight-Linespacing). This is wrong. Please note that the
coordinates(dx,dy) in the arguments of DrawTextAligned()is that of font base
line. So the top line should start from dHeight-ascent of font.(
http://www.catch22.net/img/editor10.gif)
Otherwise the gap from the top will be more. This will be visible for large
fonts.
So the fixed function will have the following line, replacing the corresponding
line from the old function.
default:
case ePdfVerticalAlignment_Top:
dY += (dHeight - m_pFont->GetFontMetrics()->GetAscent() +
m_pFont->GetFontMetrics()->GetLineSpacing()); break;
Regards
Ali
::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended
for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information
could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in
transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on
the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the
author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction,
dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written
consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please
delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and
other defects.
----------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users