Each page of your sample document contains text drawing instructions which draw space characters with a base line at y coordinate 39:
BT
/F2 14.04 Tf
1 0 0 1 72.024 39.024 Tm
[( )] TJ
ET
BT
1 0 0 1 306.05 39.024 Tm
[( )] TJ
ET
BT
1 0 0 1 397.63 39.024 Tm
[( )] TJ
ET
and none below that
Thus, your code will correctly return 39 + descent as bottom of the last line.
To get around this problem, you can employ the method explained and outlined in Java/iText in this answer to "TextMarginFinder to verify printability", i.e. by ignoring all space characters while calculating the text bounding box:
using (PdfReader pdfReader = new PdfReader(source))
{
System.Console.Write("\n*\n*\n* Filtered last lines per page of {0}\n*\n*\n", source);
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
PdfReaderContentParser parser = new PdfReaderContentParser(pdfReader);
TextMarginFinder finder = new TextMarginFinder();
FilteredRenderListener filtered = new FilteredRenderListener(finder, new SpaceFilter());
parser.ProcessContent(page, new TextRenderInfoSplitter(filtered));
System.Console.Write("Page {0}, Bottom y {1}\n", page, finder.GetLly());
}
}
with these two helper classes
class TextRenderInfoSplitter : IRenderListener
{
public TextRenderInfoSplitter(IRenderListener strategy) {
this.strategy = strategy;
}
public void RenderText(TextRenderInfo renderInfo) {
foreach (TextRenderInfo info in renderInfo.GetCharacterRenderInfos()) {
strategy.RenderText(info);
}
}
public void BeginTextBlock() {
strategy.BeginTextBlock();
}
public void EndTextBlock() {
strategy.EndTextBlock();
}
public void RenderImage(ImageRenderInfo renderInfo) {
strategy.RenderImage(renderInfo);
}
IRenderListener strategy;
}
class SpaceFilter : RenderFilter
{
public override bool AllowText(TextRenderInfo renderInfo)
{
return renderInfo != null && renderInfo.GetText().Trim().Length > 0;
}
}
The output for your sample document is:
*
*
* Filtered last lines per page of PACACH0123.pdf
*
*
Page 1, Bottom y 81,92254
Page 2, Bottom y 413,1685
Page 3, Bottom y 688,4785
This looks more like the numbers you are after.