Hi All,
I want to remove all tables, images, charts and graphs from the pdf file.
I tried to remove image which is working fine but problem is while removing tables and charts.
I have also tried using TableAbsorber() but it is not able to detect table from the pdf file.
I have attached the sample pdf file.
Please anyone help me to resolve this issue.
Thanks in advance.
Hi Moin,
Aspose.Pdf.Facades.PdfAnnotationEditor editor
= new
Aspose.Pdf.Facades.PdfAnnotationEditor();<o:p></o:p>
editor.BindPdf("c:/pdftest/Sample+File.pdf");
// Create TableAbsorber object to find tables
Aspose.Pdf.Text.TableAbsorber absorber = new Aspose.Pdf.Text.TableAbsorber();
// Visit first page with absorber
absorber.Visit(editor.Document.Pages[1]);
// Getting the table rectangle
Aspose.Pdf.Rectangle rect = absorber.TableList[0].Rectangle;
// clear text for the table
foreach (Aspose.Pdf.Text.AbsorbedRow row in absorber.TableList[0].RowList)
{
foreach (Aspose.Pdf.Text.AbsorbedCell cell in row.CellList)
{
foreach (Object fragment in cell.TextFragments)
{
((Aspose.Pdf.Text.TextFragment)fragment).Text="";
}
}
}
//Need to add a pixel to delete the border
rect.LLX = rect.LLX - 1;
rect.LLY=rect.LLY- 1;
rect.URX=rect.URX+ 1;
rect.URY=rect.URY + 1;
editor.RedactArea(1, rect, System.Drawing.Color.White);
editor.Save("c:/pdftest/TableRemopved.pdf");
Hello,
A few points to note.:-
1.) I am getting an error at ‘absorber.Visit(editor.Document.Pages[1]);’… The error i get is ‘Internal error occured during work of TableAbsorber’… please help as soon as possible.
2.) You said, Aspose.pdf does not remove charts, but in the output file that you have attached, shows that the chart has been removed on the first page.
3.) The tables have not been removed on page 1 as you have mentioned in the code.
If there is a way to have a direct conversation please let us know as this problem is very urgent.
Feel free to contact us on skype on any of the following IDs:-
ftb_jay
ftb_purab
ftb_gautam
Thank you.
Hi Moin,m2pathan:
1.) I am getting an error at ‘absorber.Visit(editor.Document.Pages[1]);’… The error i get is ‘Internal error occured during work of TableAbsorber’… please help as soon as possible.
The charts appears to be rendered inside first table of PDF document.m2pathan:
2.) You said, Aspose.pdf does not remove charts, but in the output file that you have attached, shows that the chart has been removed on the first page.
In order to remove other tables, please change the index for tablesm2pathan:
3.) The tables have not been removed on page 1 as you have mentioned in the code.
//
Getting the table rectangle<o:p></o:p>
Aspose.Pdf.Rectangle rect = absorber.TableList[2].Rectangle;