Free Support Forum - aspose.com

Remove border of row of existing pdf table

Hi

I am working on manipulating existing PDF table, and want to remove the border of the first row of each table.
For a newly created table we can alter table border using :
table.setBorder(new BorderInfo(BorderSide.All, 1F));

But for an AbsorbedTable/AbsorbedRow etc how can we remove border?
Below is my code snippet for getting table, rows and redacting select area.

public void identifyTables(@NonNull Document document, Map<String,String> tableKeyWords){

        TableAbsorber absorber = null;
        PdfAnnotationEditor editor = new PdfAnnotationEditor();
        editor.bindPdf(document);

        for(int i = 1; i <= document.getPages().size(); i++) {// loop through pages
            System.out.println(" ******** Page : " +  i + " **********");
            absorber = new TableAbsorber();
            absorber.visit(document.getPages().get_Item(i));
            System.out.println(absorber.getTableList().size());
            for(int j = 0; j < absorber.getTableList().size(); j++) { // loop through tables
                System.out.println(" ******* Table number : " + j + " *******");
                for (AbsorbedRow row : absorber.getTableList().get_Item(j).getRowList()) { // loop through rows
                    editor.redactArea(i, row.getRectangle(), Color.WHITE);
                    break;
                }
            }
        }
        editor.save("src/test/resources/rem-output.pdf");
        
    }

@Mojo3991

Thank you for contacting support.

If you want to remove the border line only then we are afraid AbsorbedTable or AbsorbedRow class may not detect the lines on the page. Only textual information can be manipulated from a table on existing PDF document. Moreover, your code snippet will be redacting the whole area returned by row.getRectangle() so this approach may neither work.

1 Like