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");
}
}
}