Проблема с размером нижних проиндексированных букв, таких как: j, p, q, g и т. Д. Внутри файлов PDF - PullRequest
0 голосов
/ 10 декабря 2018

Уважаемые участники переполнения стека ...

Я пытаюсь охватить слова в PDF.Я выбрал слово «informacji» для удаления из всего файла PDF.Проблема в том, что я не могу получить правильный размер буквы: «j» - в этом случае.enter image description here

Кто-то более умный, может догадаться, что написано за ним.

Я реализовал свой собственный класс, унаследованный от 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;
    }
}

Любая помощь приветствуется.

1 Ответ

0 голосов
/ 10 декабря 2018

Вы используете базовую линию и добавляете нижний предел вашего прямоугольника:

Vector startLine = renderInfo.GetBaseline().GetStartPoint();

Если вы хотите покрыть буквы и частями ниже базовой линии, вы должны использовать вместо этого линию спуска:

Vector startLine = renderInfo.GetDescentLine().GetStartPoint();
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...