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 Apr 20, 2023 3:54 am

Sample Data:
https://drive.google.com/file/d/1C8UKPa ... sp=sharing

Code: Select all
  string str= @"D:\tabletest.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
                        Workbook workbook = new Workbook();
                        workbook.CreateEmptySheets(1);
                        Worksheet sheet = workbook.Worksheets[0];

                        //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);
                                sheet.Range[iRow + 1, iCol + 1].Value = text;                             
                            }                       
                        }                   

                        //Save your file
                        string strExcel = strTargetPage + "_" + DateTime.Now.ToString("yyyyMMddHHmmss.fff") + ".xlsx";                       
                        workbook.SaveToFile(strExcel);                 
                 
                }
            }


Result: Table is getting outside text.
table2.JPG

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

Thu Apr 20, 2023 11:50 am

Hi,

Thanks for your feedback.
I did reproduce your issue after testing your files. I have logged this issue into our tracking system with the ticket SPIREPDF-5951, our Dev team will do further investigation and fixing. Once there is any update, we will keep you informed. Sorry for the inconvenience caused.

Best Regards,
Herman
E-iceblue support team
User avatar

Herman.Yan
 
Posts: 115
Joined: Wed Mar 08, 2023 2:00 am

Wed May 24, 2023 4:15 am

Hello,

Glad to inform that we just released Spire.PDF Pack(Hot Fix) Version:9.5.4 which included the optimizations for the issue of SPIREPDF-5951. But it still extracted a little of outside text. Since PDF itself does not have the table attributes and our product extracted table cell data based on the combination lines on the PDF page. On the outside of your document table, it has combination lines similar to cells , currently it is difficult to exclude all of them.
You can download the latest version from the following links to test firstly.
Website link: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/9.5.4

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1533
Joined: Wed Apr 25, 2018 3:20 am

Fri May 26, 2023 3:29 am

Init Document very long at first time
Code: Select all
DateTime start = DateTime.Now;
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
DateTime end = DateTime.Now;
double  second = (end - start).TotalSeconds;


Result: second = 189 (s)

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

Fri May 26, 2023 9:54 am

Hello,

Thanks for your feedback.
I did an initial test with your code, it took less than 1 second. What is your project type and environment? To help us have an accurate investigation, could you please share the following more information with us? Thanks in advance.
1. Your project type, such as .NET Core3.1.
2. Your system information (E.g. Win10, 64 bit) and region setting (E.g. China, Chinese).
3. Or you can upload your whole project to the DropBox or OneDrive and then share the download link with us for a better reference.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1533
Joined: Wed Apr 25, 2018 3:20 am

Mon May 29, 2023 3:01 am

1. Net Framwork 4.6
2. Win 10 64bit
3. https://drive.google.com/file/d/1ft7c3U ... share_link

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

Mon May 29, 2023 10:36 am

Hello,

Thanks for your more information.
My system also is Win 10 64bit, after running your project with my VS 2022, it just cost about 0.16s. I attached my testing result screenshot for your better reference. As for your situation, I suggest that you try to test on other machines and then let us know your further testing result.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1533
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF

cron