Logout Developer Knowledgebase Search Adobe Partners Main Adobe Solution Partner Finder Adobe Solution Partner Program Support Developer Knowledgebase Adobe Solution Partner Program Products & Technology Adobe
Developer Knowledgebase

Knowledgebase HomeInDesign KB

Overview
Software Development Kits
Developer Knowledgebase
Support
Legal Notices
Feedback
Adobe Solution Partner Program
Join
Find a Solution Partner

Product
InDesign
 
Version
2.0, CS
 
Last Edited
31-May-2005
 
Document
52324

How To: Delete a page from a document

Summary
This document describes how to open a document, delete a page, save and close the document. To delete a page, use kDeletePageCmdBoss.

Issue:
I want to delete a page from my document. How do I do that?

Solution:
If you have an open document, first get the page list (IPageList, aggregated by kDocBoss) and then get the UID of the Page, which you want to delete. Using IPageList::GetNthPageUID() you could get the page UID. Then create and process the kDeletePageCmdBoss by passing the UID of the page in the item list of the command. The following code snippet describes the step discussed for deleting the first page of the document:

#include "SpreadID.h" // For kDeleteSpreadCmdBoss

ErrorCode status = kFailure;

InterfacePtr<IApplication> myApp(gSession->QueryApplication());
InterfacePtr<IDocumentList> myDocList(myApp->QueryDocumentList());
//Get the first document
IDocument *doc = myDocList->GetNthDoc(0);
if (doc != nil)
{
    UID myPageUID;
    UIDRef myPageUIDRef;
    //Get the page list of the document
    InterfacePtr<IPageList> myPageList(doc, UseDefaultIID());
    if (myPageList != nil)
    {
        //Get the UIDRef to the page you want to delete
        myPageUID = myPageList->GetNthPageUID(0);
        myPageUIDRef = UIDRef(::GetDataBase(doc), myPageUID);

        // Create a DeletePageCmd:
        InterfacePtr<ICommand> deleteCmd(CmdUtils::CreateCommand(kDeletePageCmdBoss));
        if ( deleteCmd != nil )
        {
            // Set the DeletePageCmd's ItemList:
            deleteCmd->SetItemList(UIDList(myPageUIDRef));
            // Process the DeletePageCmd:
            status = CmdUtils::ProcessCommand(deleteCmd);
        }
    }
}
else
    ASSERT_FAIL("document invalid");

The attached file is the InDesign 2.x code snippet, which shows how to how to open a document, delete a page, save and close the document.

Supporting Files
SnipDeletePageFromDoc.cpp

back to top
Was this Knowledgebase document helpful? Yes  No
The articles in this knowledgebase are intended for use by software programmers currently using an Adobe SDK to extend or customize an Adobe product. These articles may be highly technical in nature.
If you have questions about an Adobe Product that are not related to development or an SDK product please visit: http://adobe.com/support/main.html
Copyright © Adobe Systems Incorporated. All rights reserved.
Terms of Use
Online Privacy Policy