Skip to content

How to crop a pdf page? #306

Discussion options

You must be logged in to vote

Found the answer! after extracting the words I was able to check if the words were inside a given rectangle.

My code:

foreach (var page in document.GetPages())
{
    var areaWithoutBorders = new PdfRectangle(0, 75, page.Width, page.Height - 125);
    var words = page.GetWords().Where(w => areaWithoutBorders.Contains(w.BoundingBox)).ToList();
    var pageText = string.Join(" ", words);
    stringBuilder.Append(pageText);
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TomColdenhoff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant