- Code: Select all
string str= @"D:\t2.pdf";
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(str);
PdfTableExtractor extractor = new PdfTableExtractor(doc);
PdfTable[] tableLists = extractor.ExtractTable(0);
if (tableLists != null && tableLists.Length > 0)
{
//Loop through the table in the list
foreach (PdfTable table in tableLists)
{
//Get row number and column number of a certain table
int iTotalRow = table.GetRowCount();
int iTotalCol = table.GetColumnCount();
//OutputExcel
//Loop though the row and colunm
for (int iRow = 0; iRow < iTotalRow; iRow++)
{
for (int iCol = 0; iCol < iTotalCol; iCol++)
{
//Get text from the specific cell
string text = table.GetText(iRow, iCol);
worksheet.Cells[iRow + 1, iCol + 1].Value = text;
}
}
}
}
Table:
Result:
Can merge cells at Column A the same PDF Table? (Which blank cells are part of Merged Cell?)