Уважаемые участники переполнения стека ...
Я пытаюсь охватить слова в PDF.Я выбрал слово «informacji» для удаления из всего файла PDF.Проблема в том, что я не могу получить правильный размер буквы: «j» - в этом случае.
Кто-то более умный, может догадаться, что написано за ним.
Я реализовал свой собственный класс, унаследованный от LocationTextExtractionStrategy
, вот код:
public override void RenderText(TextRenderInfo renderInfo)
{
LineSegment segment = renderInfo.GetBaseline();
if (renderInfo.GetRise() != 0)
{ // remove the rise from the baseline - we do this because the text from a super/subscript render operations should probably be considered as part of the baseline of the text the super/sub is relative to
Matrix riseOffsetTransform = new Matrix(0, -renderInfo.GetRise());
segment = segment.TransformBy(riseOffsetTransform);
}
var fnt= renderInfo.GetFont();
TextChunk tc = new TextChunk(renderInfo.GetText(), tclStrat.CreateLocation(renderInfo, segment));
Vector startLine = renderInfo.GetBaseline().GetStartPoint();
Vector endLineTopRight = renderInfo.GetAscentLine().GetEndPoint();
Rectangle textRectangle = new Rectangle(startLine[Vector.I1], startLine[Vector.I2], endLineTopRight[Vector.I1], endLineTopRight[Vector.I2]);
TextInfo textInfo = new TextInfo(tc, textRectangle);
locationalResult.Add(textInfo);
}
и несколько строк кода позже, я добавляю значения объекта textRectangle
в список объектов wordList[wordList.Count-1].rectanglesToDraw.Add(new SquaresToDraw(page, text.textRectangle.Left, text.textRectangle.Bottom, text.textRectangle.Right, text.textRectangle.Top));
Теперь дополнительная информация (ничего особенного, imo):
RectanglesToDraw
- это список SquaresToDraw
, а SquaresToDraw
- это класс, который выглядит следующим образом:
public class SquaresToDraw
{
public int pageNumber { get; set; }
public float left { get; set; }//llx
public float bottom { get; set; } //lly
public float right { get;set;} //rux
public float top { get; set; }//ruy
public SquaresToDraw(int pageNumber,float left, float bottom, float right,float top)
{
this.pageNumber = pageNumber;
this.left = left;
this.right = right;
this.bottom = bottom;
this.top = top;
}
}
Любая помощь приветствуется.