Skip to content

Commit d43089d

Browse files
committed
Add helper method to get the line to which a word belongs
1 parent 28a7260 commit d43089d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Caly.Pdf/Models/PdfTextLayer.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ public PdfTextLayer(IReadOnlyList<PdfTextBlock> textBlocks, IReadOnlyList<PdfAnn
105105
return null;
106106
}
107107

108+
public PdfTextLine? GetLine(PdfWord word)
109+
{
110+
var block = TextBlocks[word.TextBlockIndex];
111+
int lineStartIndex = block.TextLines[0].IndexInPage;
112+
return block.TextLines[word.TextLineIndex - lineStartIndex];
113+
}
114+
108115
public IEnumerable<PdfWord> GetWords(PdfWord start, PdfWord end)
109116
{
110117
System.Diagnostics.Debug.Assert(start.IndexInPage <= end.IndexInPage);

0 commit comments

Comments
 (0)