Problems in delete the whole table

Hi,

I tried to delete the whole table using bookmark in Aspose. But I find that I can just delete the table, but not the content inside. So is it correct? Or I can use any approach to delete the content also?

Attached is the sample document and result. We would like to delete the bookmark RIDERPLANS_BOOKMARK. But you can see the dollar sign is still in PDF

Regards,
Ken Wan

Hi

Thanks for your inquiry. I cannot reproduce the problem on my side. The following code works without any issues:

Document doc = new Document(@"Test\PPS_WLPR_ENG.doc");
// Get bookmark
Bookmark bk = doc.Range.Bookmarks["RIDERPLANS_BOOKMARK"];
if (bk != null)
{
    // Get table, where bookmark is located.
    Node table = bk.BookmarkStart.GetAncestor(NodeType.Table);
    if (table != null)
        table.Remove();
}
doc.Save(@"Test\out.doc");
doc.SaveToPdf(@"Test\out.pdf");

The output PDF generated on my side looks fine. I sent it to your e-mail.
Best regards,

Hi,

Is that you the problem is you remove before you do the mail merge? May be the problem is we mail merge before we delete the table?

Regards,
Ken Wan

Hi

Thank you for additional information. You can easily check this, please see the following code:

Document doc = new Document(@"Test\PPS_WLPR_ENG.doc");
// Execute MailMerge with regions
doc.MailMerge.ExecuteWithRegions(GetTableData());
// Get bookmark
Bookmark bk = doc.Range.Bookmarks["RIDERPLANS_BOOKMARK"];
if (bk != null)
{
    // Get table, where bookmark is located.
    Node table = bk.BookmarkStart.GetAncestor(NodeType.Table);
    if (table != null)
        table.Remove();
}
doc.Save(@"Test\out.doc");
doc.SaveToPdf(@"Test\out.pdf");
private DataTable GetTableData()
{
    // Create data table
    DataTable table = new DataTable("TB001S");
    table.Columns.Add("rider");
    table.Columns.Add("initRiderFaceAmt");
    table.Columns.Add("ccySign");
    table.Columns.Add("initRiderPrem");
    // Add some dummy data.
    table.Rows.Add(new object[]
    {
        "rider",
        "initRiderFaceAmt",
        "ccySign",
        "initRiderPrem"
    });
    table.Rows.Add(new object[]
    {
        "rider",
        "initRiderFaceAmt",
        "ccySign",
        "initRiderPrem"
    });
    table.Rows.Add(new object[]
    {
        "rider",
        "initRiderFaceAmt",
        "ccySign",
        "initRiderPrem"
    });
    return table;
}

The table has been deleted successfully.
Could you please create a simple application which will allow me to reproduce the problem on my side?
Best regards,