diff --git a/src/UglyToad.PdfPig/DocumentLayoutAnalysis/RecursiveXYCut.cs b/src/UglyToad.PdfPig/DocumentLayoutAnalysis/RecursiveXYCut.cs index 7893e71e..102a8679 100644 --- a/src/UglyToad.PdfPig/DocumentLayoutAnalysis/RecursiveXYCut.cs +++ b/src/UglyToad.PdfPig/DocumentLayoutAnalysis/RecursiveXYCut.cs @@ -18,37 +18,37 @@ namespace UglyToad.PdfPig.DocumentLayoutAnalysis /// Get the blocks. /// /// The words in a page. - /// The minimum widht for a block. + /// The minimum width for a block. /// The dominant font width. /// The dominant font height. /// - public static XYNode GetBlocks(IEnumerable pageWords, decimal minimumWidht, + public static XYNode GetBlocks(IEnumerable pageWords, decimal minimumWidth, decimal dominantFontWidth, decimal dominantFontHeight) { - return GetBlocks(pageWords, minimumWidht, k => dominantFontWidth, k => dominantFontHeight); + return GetBlocks(pageWords, minimumWidth, k => dominantFontWidth, k => dominantFontHeight); } /// /// Get the blocks. /// /// The words in a page. - /// The minimum widht for a block. + /// The minimum width for a block. /// The function that determines the dominant font width. /// The function that determines the dominant font height. /// - public static XYNode GetBlocks(IEnumerable pageWords, decimal minimumWidht, + public static XYNode GetBlocks(IEnumerable pageWords, decimal minimumWidth, Func, decimal> dominantFontWidthFunc, Func, decimal> dominantFontHeightFunc) { var root = new XYLeef(pageWords); - return VerticalCut(root, minimumWidht, dominantFontWidthFunc, dominantFontHeightFunc); + return VerticalCut(root, minimumWidth, dominantFontWidthFunc, dominantFontHeightFunc); } - private static XYNode VerticalCut(XYLeef leef, decimal minimumWidht, + private static XYNode VerticalCut(XYLeef leef, decimal minimumWidth, Func, decimal> dominantFontWidthFunc, Func, decimal> dominantFontHeightFunc, int level = 0) { - if (leef.CountWords() <= 1 || leef.BoundingBox.Width <= minimumWidht) + if (leef.CountWords() <= 1 || leef.BoundingBox.Width <= minimumWidth) { // we stop cutting if // - only one word remains @@ -103,7 +103,7 @@ namespace UglyToad.PdfPig.DocumentLayoutAnalysis // |____| |____| currentProj[1] = words[i].BoundingBox.Right; } - else if (currentProj[1] - currentProj[0] < minimumWidht) + else if (currentProj[1] - currentProj[0] < minimumWidth) { // still too small currentProj[1] = words[i].BoundingBox.Right; @@ -125,7 +125,7 @@ namespace UglyToad.PdfPig.DocumentLayoutAnalysis var newLeefsEnums = projectionProfile.Select(p => leef.Words.Where(w => w.BoundingBox.Left >= p[0] && w.BoundingBox.Right <= p[1])); var newLeefs = newLeefsEnums.Where(e => e.Count() > 0).Select(e => new XYLeef(e)); - var newNodes = newLeefs.Select(l => HorizontalCut(l, minimumWidht, + var newNodes = newLeefs.Select(l => HorizontalCut(l, minimumWidth, dominantFontWidthFunc, dominantFontHeightFunc, level)).ToList(); var lost = leef.Words.Except(newLeefsEnums.SelectMany(x => x)).Where(x => !string.IsNullOrWhiteSpace(x.Text)).ToList(); @@ -137,7 +137,7 @@ namespace UglyToad.PdfPig.DocumentLayoutAnalysis return new XYNode(newNodes); } - private static XYNode HorizontalCut(XYLeef leef, decimal minimumWidht, + private static XYNode HorizontalCut(XYLeef leef, decimal minimumWidth, Func, decimal> dominantFontWidthFunc, Func, decimal> dominantFontHeightFunc, int level = 0) { @@ -210,7 +210,7 @@ namespace UglyToad.PdfPig.DocumentLayoutAnalysis var newLeefsEnums = projectionProfile.Select(p => leef.Words.Where(w => w.BoundingBox.Bottom >= p[0] && w.BoundingBox.Top <= p[1])); var newLeefs = newLeefsEnums.Where(e => e.Count() > 0).Select(e => new XYLeef(e)); - var newNodes = newLeefs.Select(l => VerticalCut(l, minimumWidht, + var newNodes = newLeefs.Select(l => VerticalCut(l, minimumWidth, dominantFontWidthFunc, dominantFontHeightFunc, level)).ToList(); var lost = leef.Words.Except(newLeefsEnums.SelectMany(x => x)).Where(x => !string.IsNullOrWhiteSpace(x.Text)).ToList();