Hi,
Hi
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. I think, in your case, you can insert bookmark into each table, which can be removed and use this bookmark as identifier. If there is no data, you just remove table, which contains the appropriate bookmark. Code to remove table will look like the following:
Document doc = new Document(@"in.doc");
// Get bookmark
Bookmark bk = doc.Range.Bookmarks["MYREGION_BOOKMARK"];
if (bk != null)
{
// Get table, where bookmark is located.
Node table = bk.BookmarkStart.GetAncestor(NodeType.Table);
if (table != null)
table.Remove();
}
doc.Save(@"out.doc");
But note, Bookmark should be inside a table, which should be removed.
Hope this helps.
Best regards.
Hi,
You may also want to look at the code from this thread below.
https://forum.aspose.com/t/67539
It will remove any empty regions from a document. It is programmed in .NET though, if it is needed and you are unable to translate to Java we will be glad to assist.
Thanks,
Hi there,
Yes that is the correct method in which to call the class. In your case in sounds as if at least one field from your region is being merged and therefore the TableStart and TableEnd markers are being removed automatically. The code above was designed to remove empty regions that were completly unmerged and still had the start and end markers present.
It should be fairly easy to modify the code to achieve what you described above. Could you please attach your document and code here and I will be glad to help you further.
Thanks,
Hi
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. Yes, behavior was changed. Earlier version removed empty regions, but the latest version of Aspose.Words just leave them untouched.
Best regards.
Thanks all, my final code is: