2 Commits
1_5 ... 1_5_1

3 changed files with 11 additions and 7 deletions

View File

@@ -11,4 +11,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: Guid("a5825d8e-9f81-49e0-b610-8ae5e46d02ea")] [assembly: Guid("a5825d8e-9f81-49e0-b610-8ae5e46d02ea")]
[assembly: AssemblyVersion("1.5.0.*")] [assembly: AssemblyVersion("1.5.1.*")]

View File

@@ -601,7 +601,7 @@ namespace VAR.PdfTools
} }
FlushTextElement(); FlushTextElement();
} }
private void JoinTextElements() private void JoinTextElements()
{ {
var textElementsCondensed = new List<PdfTextElement>(); var textElementsCondensed = new List<PdfTextElement>();
@@ -625,10 +625,12 @@ namespace VAR.PdfTools
double neighbourY = neighbour.GetY(); double neighbourY = neighbour.GetY();
if (Math.Abs(neighbourY - blockY) > 0.001) { i++; continue; } if (Math.Abs(neighbourY - blockY) > 0.001) { i++; continue; }
double maxWidth = neighbour.Characters.Max(c => c.Width);
double neighbourXMin = neighbour.GetX(); double neighbourXMin = neighbour.GetX();
double neighbourXMax = neighbourXMin + neighbour.VisibleWidth; double neighbourXMax = neighbourXMin + neighbour.VisibleWidth;
double auxBlockXMin = blockXMin - (elem.FontSize * elem.Font.GetCharWidth('m')); double auxBlockXMin = blockXMin - maxWidth;
double auxBlockXMax = blockXMax + (elem.FontSize * elem.Font.GetCharWidth('m')); double auxBlockXMax = blockXMax + maxWidth;
if (auxBlockXMax >= neighbourXMin && neighbourXMax >= auxBlockXMin) if (auxBlockXMax >= neighbourXMin && neighbourXMax >= auxBlockXMin)
{ {
_textElements.Remove(neighbour); _textElements.Remove(neighbour);
@@ -693,13 +695,15 @@ namespace VAR.PdfTools
{ {
PdfTextElement elem = _textElements[0]; PdfTextElement elem = _textElements[0];
_textElements.Remove(elem); _textElements.Remove(elem);
double maxWidth = elem.Characters.Max(c => c.Width);
int prevBreak = 0; int prevBreak = 0;
for (int i = 1; i < elem.Characters.Count; i++) for (int i = 1; i < elem.Characters.Count; i++)
{ {
double prevCharEnd = elem.Characters[i - 1].Displacement + elem.Characters[i - 1].Width; double prevCharEnd = elem.Characters[i - 1].Displacement + elem.Characters[i - 1].Width;
double charSeparation = elem.Characters[i].Displacement - prevCharEnd; double charSeparation = elem.Characters[i].Displacement - prevCharEnd;
if (charSeparation > (elem.Characters[i - 1].Width * 2)) if (charSeparation > maxWidth)
{ {
PdfTextElement partElem = elem.SubPart(prevBreak, i); PdfTextElement partElem = elem.SubPart(prevBreak, i);
textElementsSplitted.Add(partElem); textElementsSplitted.Add(partElem);

View File

@@ -11,4 +11,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: Guid("eb7e003a-6a95-4002-809f-926c7c8a11e9")] [assembly: Guid("eb7e003a-6a95-4002-809f-926c7c8a11e9")]
[assembly: AssemblyVersion("1.5.0.*")] [assembly: AssemblyVersion("1.5.1.*")]