Refactorings
This commit is contained in:
@@ -89,13 +89,15 @@ namespace VAR.PdfTools
|
||||
{
|
||||
if (elem is PdfReal widthReal)
|
||||
{
|
||||
_widths.Add(actualChar, widthReal.Value / glyphSpaceToTextSpace);
|
||||
double charWidth = widthReal.Value / glyphSpaceToTextSpace;
|
||||
_widths.Add(actualChar, charWidth);
|
||||
actualChar++;
|
||||
continue;
|
||||
}
|
||||
if (elem is PdfInteger widthInt)
|
||||
{
|
||||
_widths.Add(actualChar, widthInt.Value / glyphSpaceToTextSpace);
|
||||
double charWidth = widthInt.Value / glyphSpaceToTextSpace;
|
||||
_widths.Add(actualChar, charWidth);
|
||||
actualChar++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace VAR.PdfTools
|
||||
public PdfTextExtractor(PdfDocumentPage page)
|
||||
{
|
||||
_page = page;
|
||||
ProcessPage();
|
||||
ProcessPageContent();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -481,9 +481,14 @@ namespace VAR.PdfTools
|
||||
{
|
||||
foreach (char c in text)
|
||||
{
|
||||
_textWidth += _font.GetCharWidth(c) * _fontSize;
|
||||
double charWidth = _font.GetCharWidth(c) * _fontSize;
|
||||
_textWidth += charWidth;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_textWidth += text.Length * _fontSize * 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpTextPutMultiple(PdfArray array)
|
||||
@@ -497,8 +502,8 @@ namespace VAR.PdfTools
|
||||
}
|
||||
else if(elem is PdfInteger || elem is PdfReal)
|
||||
{
|
||||
double spacing = PdfElementUtils.GetReal(elem, 0);
|
||||
// FIXME: Apply correctly spacing
|
||||
//double spacing = PdfElementUtils.GetReal(elem, 0);
|
||||
//_textWidth += spacing;
|
||||
}
|
||||
else if(elem is PdfArray)
|
||||
@@ -512,7 +517,7 @@ namespace VAR.PdfTools
|
||||
|
||||
#region Private methods
|
||||
|
||||
private void ProcessPage()
|
||||
private void ProcessPageContent()
|
||||
{
|
||||
int unknowCount = 0;
|
||||
for (int i = 0; i < _page.ContentActions.Count; i++)
|
||||
|
||||
Reference in New Issue
Block a user