Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Mar 09, 2023 7:00 am

I know extract table on a Page by code:
Code: Select all
var doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(strFile);
PdfTableExtractor extractor = new PdfTableExtractor(doc);
PdfTable[] tableLists = extractor.ExtractTable(0);


But my Page have multi tables, Can i extract only a table by Position of Table?

daitranthanhhoa
 
Posts: 51
Joined: Mon Sep 19, 2016 3:04 am

Thu Mar 09, 2023 7:52 am

Hello,

Thanks for your inquiry.
Sorry that our product doesn’t support extract table according to the position of table.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 964
Joined: Tue Mar 08, 2022 2:02 am

Fri Mar 10, 2023 7:55 am

I think, you must add it as a new feature.
To result of table will better
Ex: My PDF have table,
t1.png


Result is not good:
t2.png


Sample data: https://drive.google.com/file/d/1lGL6BW ... sp=sharing

daitranthanhhoa
 
Posts: 51
Joined: Mon Sep 19, 2016 3:04 am

Fri Mar 10, 2023 10:16 am

Hello,

Thanks for your feedback.
According to the message you provided, Are you currently converting the pdf to excel and then doing further processing? Could you describe your requirements in more detail? For example, what are the operations after you obtain the table? Please offer your Pdf file, you can attach here or send it to us via email (support@e-iceblue.com). I’ll see if there are other solutions to meet your requirements. Thanks for your assistance in advance.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 964
Joined: Tue Mar 08, 2022 2:02 am

Mon Mar 13, 2023 3:39 am

I only get list table and output to excel file:
Code: Select all
string strTargetPage = @"D:\admin\SpirePDF\tabletest.pdf";
            var doc = new Spire.Pdf.PdfDocument();
            doc.LoadFromFile(strTargetPage);
            PdfTableExtractor extractor = new PdfTableExtractor(doc);
            PdfTable[] tableLists = null;
            tableLists = extractor.ExtractTable(0);
           foreach (PdfTable table in tableLists)
                {
                    //Get row number and column number of a certain table
                    int iTotalRow = table.GetRowCount();
                    int iTotalCol = table.GetColumnCount();
                    for (int iRow = 0; iRow < iTotalRow; iRow++)
                        {
                            for (int iCol = 0; iCol < iTotalCol; iCol++)
                            {
                             
                                string text = table.GetText(iRow, iCol);

                                worksheet.Cells[iRow + 1, iCol + 1].Value = text;
                            }
                   }
               }

Data Sample i had attach pre comment.

daitranthanhhoa
 
Posts: 51
Joined: Mon Sep 19, 2016 3:04 am

Mon Mar 13, 2023 9:56 am

Hello,

Thanks for your feedback.
Sorry, table extraction by table location is not available, but you can first convert Pdf file to Excel file then do further process. The following screenshot show the effect of converting pdf to excel.

Code: Select all
PdfDocument pdfDocument = new PdfDocument();
            pdfDocument.LoadFromFile(@"../../data/tabletest.pdf");

            pdfDocument.SaveToFile(@"../../output/result.xlsx",FileFormat.XLSX);


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 964
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF