diff --git a/VAR.PdfTools/PdfFont.cs b/VAR.PdfTools/PdfFont.cs index 2cb7658..dbe6ebc 100644 --- a/VAR.PdfTools/PdfFont.cs +++ b/VAR.PdfTools/PdfFont.cs @@ -87,7 +87,9 @@ namespace VAR.PdfTools char actualChar = firstChar; foreach (IPdfElement elem in widths.Values) { - _widths.Add(actualChar, PdfElementUtils.GetReal(elem, 500) / glyphSpaceToTextSpace); + double width = PdfElementUtils.GetReal(elem, 500); + if (width < 0.0001f && width > -0.0001f) { width = 500; } + _widths.Add(actualChar, width / glyphSpaceToTextSpace); actualChar++; } // FIMXE: Calculate real height diff --git a/VAR.PdfTools/PdfTextExtractor.cs b/VAR.PdfTools/PdfTextExtractor.cs index 2cce91a..2dd07c1 100644 --- a/VAR.PdfTools/PdfTextExtractor.cs +++ b/VAR.PdfTools/PdfTextExtractor.cs @@ -125,7 +125,8 @@ namespace VAR.PdfTools textElem.Matrix = _textMatrixCurrent.Multiply(_graphicsMatrix); textElem.RawText = _sbText.ToString(); textElem.VisibleText = PdfString_ToUnicode(textElem.RawText, _font); - textElem.VisibleWidth = _textWidth * textElem.Matrix.Matrix[0, 0]; + PdfCharElement lastChar = _listCharacters[_listCharacters.Count - 1]; + textElem.VisibleWidth = (lastChar.Displacement + lastChar.Width) * textElem.Matrix.Matrix[0, 0]; textElem.VisibleHeight = (_font.Height * _fontSize) * textElem.Matrix.Matrix[1, 1]; textElem.Characters = new List(); foreach (PdfCharElement c in _listCharacters)