PdfCharElement: Width attribute

This commit is contained in:
2017-10-11 16:47:10 +02:00
parent 6b8bbc367f
commit 34e7424273
2 changed files with 10 additions and 4 deletions

View File

@@ -250,9 +250,8 @@ namespace VAR.PdfTools.Workbench
(int)(textElementPageY * Scale),
(int)(textElementWidth * Scale),
(int)(textElementHeight * Scale),
Scale);
5);
using (Font font = new Font("Arial", (int)(textElementHeight * Scale), GraphicsUnit.Pixel))
{
foreach (PdfCharElement c in textElement.Characters)
@@ -266,6 +265,10 @@ namespace VAR.PdfTools.Workbench
(int)((textElementPageX + c.Displacement) * Scale),
(int)(textElementPageY * Scale),
2, 2);
gc.FillRectangle(Brushes.Green,
(int)((textElementPageX + c.Displacement + c.Width) * Scale),
(int)(textElementPageY * Scale),
2, 2);
}
}
}

View File

@@ -11,6 +11,7 @@ namespace VAR.PdfTools
{
public string Char;
public double Displacement;
public double Width;
}
public class PdfTextElement
@@ -135,6 +136,7 @@ namespace VAR.PdfTools
{
Char = c.Char,
Displacement = (c.Displacement * textElem.Matrix.Matrix[0, 0]),
Width = (c.Width * textElem.Matrix.Matrix[0, 0]),
});
}
textElem.Childs = new List<PdfTextElement>();
@@ -321,8 +323,8 @@ namespace VAR.PdfTools
{
string realChar = _font.ToUnicode(c);
if (realChar == "\0") { continue; }
_listCharacters.Add(new PdfCharElement { Char = _font.ToUnicode(c), Displacement = _textWidth, });
double charWidth = _font.GetCharWidth(c) * _fontSize;
_listCharacters.Add(new PdfCharElement { Char = _font.ToUnicode(c), Displacement = _textWidth, Width = charWidth });
_textWidth += charWidth;
_textWidth += ((c == 0x20) ? _wordSpacing : _charSpacing);
}
@@ -620,6 +622,7 @@ namespace VAR.PdfTools
{
Char = c.Char,
Displacement = (c.Displacement + neighbourXMin) - blockXMin,
Width = c.Width,
});
}
}