We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How I should get the tables in the pdf the correct location

In the PDF,
I get the location of the tables drawn on the picture is not right,
how I should get the tables in the pdf the correct location.
Thank you very much.

   public static void Extract_Table()
    {
        // Load source PDF document
        var filePath = @"C:\Users\小马春丽\Desktop\123.pdf";
        PdfUnitConvertor unitconverter = new PdfUnitConvertor();
        Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(filePath);
        foreach (var page in pdfDocument.Pages)
        {
            Aspose.Pdf.Text.TableAbsorber absorber = new Aspose.Pdf.Text.TableAbsorber();
            absorber.Visit(page);
            foreach (AbsorbedTable table in absorber.TableList)
            {

                var sss = table.Rectangle.ToRect();
                // Load the image (probably from your stream)
                System.Drawing.Image image = System.Drawing.Image.FromFile(@"C:\Users\小马春丽\Desktop\123.png");
                //Image sourceImage = Image.FromFile(imageName);  // 读取原图

                // 创建一个新图片
                Bitmap bmp = new Bitmap(image);
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    g.DrawRectangle(new Pen(System.Drawing.Color.Red), sss);
                }

                bmp.Save(@"C:\Users\小马春丽\Desktop\123_back.png");
            }
        }
    }

123.pdf (25.5 KB)
123.png (4.6 KB)

@xiaobaobao

We are checking it and will get back to you shortly.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

  Issue ID(s): PDFNET-53516

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Also I would like to know
how to get the location of the formula in the PDF
Thank you very much!

@xiaobaobao

Is formula in the PDF is present in the form of text? If so, you can use TextFragmentAbsorber Class to extract its rectangle and position accordingly. In case you face any issues, please share your sample PDF with us so that we can further proceed to assist you accordingly.

Thank you very much for your reply!

  1. Formulas are in text form
    In the text I can’t tell which are the formulas
    Can you give me an example?
  2. Also I want to get the position and size of the tables
    How do I need to do that?
    Can you give me a simple demo of the above two questions?
    Carlberg_1997_ApJ_478_462.pdf (790.5 KB)
    formula.png (585.4 KB)
    TABLES.png (283.8 KB)

@xiaobaobao

We are checking it and will get back to you shortly.

@xiaobaobao

We have checked your PDF document and noticed that it is a complex requirement to extract only formulae and tables from it with other properties.

Hence, we have opened the following new ticket(s) in our internal issue tracking system and will let you know once it is resolved.

Issue ID(s): PDFNET-53549

We are sorry for the inconvenience.