Пожалуйста, дайте мне знать, как я могу читать в правильном порядке все несколько строк в одном столбце, и позиция порядка не устанавливается
вот мой результат:
Код: Выделить всё
4 | 0459270 | **Saif | Azim | Khan** | M&E_MST | 01-12-2021 | 100973591911 | NA | 30.00 | 27.00 | 0.00 | 0.00 | M | 11632 | 3068 | 6869 | 2455 | 2000 | 26024 | 10469 | 2761 | 6182 | 2210 | 1800 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 23422 | 0 | 23422 | 1800 | 0 | 200 | 0 | 0 | 0 | 0 | 30 | 2030 | 21392 l | a | 2361040425 e **RICIAN** | 6912158 3 | 0459269 | **Vijay | Namdeo | Kharat** | 01-12-2021 | 100619445298 | NA | 30.00 | 30.00 | 0.00 | 0.00 | M | 11632 | 3068 | 6869 | 600 | 0 | 22169 | 11632 | 3068 | 6869 | 600 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 22169 | 0 | 22169 | 1800 | 0 | 200 | 0 | 0 | 0 | 0 | 30 | 2030 | 20139 **M&E_ELECT** | l | a | 0000006011 e **Salunkhe** | 01162 2 | 0459262 | M&E_HVAC | 01-12-2021 | 101167974412 | NA | 30.00 | 30.00 | 0.00 | 0.00 | M | 11632 | 3068 | 6362 | 0 | 1788 | 22850 | 11632 | 3068 | 6362 | 0 | 1788 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 22850 | 0 | 22850 | 1800 | 0 | 200 | 0 | 0 | 0 | 0 | 30 | 2030 | 20820 **Ganesh | Sampat** | l | a | 0651001000 e 8999 1 | 0459259 |** Mohd | Akram** | M&E_HVAC | 01-12-2021 | 101621135920 | NA | 30.00 | 30.00 | 0.00 | 0.00 | M | 11632 | 3068 | 6869 | 0 | 2281 | 23850 | 11632 | 3068 | 6869 | 0 | 2281 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 23850 | 0 | 23850 | 1800 | 0 | 200 | 0 | 0 | 0 | 0 | 30 | 2030 | 21820 l | a | 0421010001Код: Выделить всё
public class PdfDataExtractor
{
public List ExtractData(Stream stream)
{
var rows = new List();
using (var document = PdfDocument.Open(stream))
{
for (int pageIndex = 0; pageIndex < document.NumberOfPages; pageIndex++)
{
var page = document.GetPage(pageIndex + 1);
// Get words on the page
var words = page.GetWords();
// Group words into rows
var groupedRows = GroupWordsIntoRows(words);
// Add grouped rows to the result
rows.AddRange(groupedRows);
}
}
return rows;
}
private List GroupWordsIntoRows(IEnumerable words)
{
var rows = new List();
var currentRow = new List();
double? currentY = null;
foreach (var word in words.OrderBy(w => w.BoundingBox.Bottom).ThenBy(w => w.BoundingBox.Left))
{
// Start a new row if the vertical position changes significantly
if (currentY.HasValue && Math.Abs(currentY.Value - word.BoundingBox.Bottom) > 5)
{
// Finalize the current row and start a new one
rows.Add(currentRow.OrderBy(w => w.x).Select(w => w.text).ToList());
currentRow = new List();
}
// Add the word to the current row
currentRow.Add((word.BoundingBox.Left, word.Text));
currentY = word.BoundingBox.Bottom;
}
// Add the last row
if (currentRow.Any())
{
rows.Add(currentRow.OrderBy(w => w.x).Select(w => w.text).ToList());
}
return rows;
}
}

У меня есть документы https://github.com/UglyToad/PdfPig/wiki, но я не могу найти решение
Подробнее здесь: https://stackoverflow.com/questions/793 ... -net-9-api
Мобильная версия