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

Free Support Forum - aspose.com

How to remove tables-charts-images-graphs from pdf

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,


Thanks for contacting support.

In order to remove table from PDF file, please try using following code snippet. For your reference, I have also attached the output generated over my end. The following code removes first table from first page of PDF file.

However I am afraid currently Aspose.Pdf for .NET does not support the feature to remove chart/graph object from PDF file. For the sake of implementation, I have logged this requirement as PDFNEWNET-40551 in our issue tracking system. We will further look into the details of these requirements and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

[C#]

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.

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.
Hi Moin,

Thanks for contacting support.

Can you please share which version of API you are using as I did not notice above stated issue when tested with Aspose.Pdf for .NET 11.4.0.

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.
The charts appears to be rendered inside first table of PDF document.

m2pathan:
3.) The tables have not been removed on page 1 as you have mentioned in the code.
In order to remove other tables, please change the index for tables

[C#]

//
Getting the table rectangle
<o:p></o:p>

Aspose.Pdf.Rectangle rect = absorber.TableList[2].Rectangle;