)
{
Page pageObj = (Page)page;
PdfDictionary pageData = pageObj.getBaseDataObject();
// Get the parent tree node!
PdfDirectObject parent = pageData.get(PdfName.Parent);
PdfDictionary parentData = (PdfDictionary)File.resolve(parent);
// Get the parent's page collection!
PdfDirectObject kids = parentData.get(PdfName.Kids);
PdfArray kidsData = (PdfArray)File.resolve(kids);
// Remove the page!
kidsData.remove(pageObj.getBaseObject());
boolean updateParent = !File.update(kids); // Try to update the page collection.
// Unbind the page from its parent!
pageData.put(PdfName.Parent,null);
pageObj.update();
// Decrementing the pages counters...
do
{
// Get the page collection counter!
PdfDirectObject count = parentData.get(PdfName.Count);
PdfNumber<?> countData = (PdfNumber<?>)File.resolve(count);
// Decrement the counter at the current level!
countData.setValue(countData.getNumberValue()-1);
updateParent |= !File.update(count); // Try to update the counter.
// Is the parent tree node to be updated?