8 Replies Latest reply: Mar 30, 2012 3:43 AM by Suraba RSS

    how to get all page items from the document

    suren_tringer

      Hi all,

       

      i want to get all page items and its frame and data from the document

      Then i want to create my own xml.

       

      any help? any advice ?please.

        • 1. Re: how to get all page items from the document
          Manan Joshi Community Member

          Pageitems are owned by the spreadlayer, you can traverse the spread and get the pageitems from it. Please refer the SDK for examples.

           

          The general way to do this is to traverse the IHierarchy interface of the parent object to get the children.

           

          Manan Joshi

           

            - Efficient InDesign Solutions -

          MetaDesign Solutions

          http://metadesignsolutions.com/services/indesign-development.php

          • 2. Re: how to get all page items from the document
            suren_tringer Community Member

            Hi joshi,

             

            i have tried the sample code for checking the possibilties ,

             

            InterfacePtr<IApplication> application(GetExecutionContextSession()->QueryApplication());

                InterfacePtr<IDocumentList> documentList(application->QueryDocumentList());

                for (int32 i = 0; i < documentList->GetDocCount(); i++) {

                    IDocument* document = documentList->GetNthDoc(i);

                    UIDRef ref=::GetUIDRef(document);

                    InterfacePtr<IHierarchy> hierarchy(ref, UseDefaultIID());       //issue,   hierachy is not getting created. it just retrun nil

                    if (hierarchy == nil)

                        break;

                    int32 count=hierarchy->GetChildCount();

            }

            • 3. Re: how to get all page items from the document
              Manan Joshi Community Member

              As i pointed out previously the owner of the Pageitems is spread layer and not the document, as far as i can recall IHierarchy won't exist on kDocBoss.

               

              You need to go to the content layer of the document and then traverse its hierarchy. Have a look at the Layout Fundamentals in the programming guide.

               

              Manan Joshi

               

                - Efficient InDesign Solutions -

              MetaDesign Solutions

              http://metadesignsolutions.com/services/indesign-development.php

              • 4. Re: how to get all page items from the document
                suren_tringer Community Member

                Hi, joshi can you suggest me any sdk samples to understand this

                • 5. Re: how to get all page items from the document
                  Dirk Becker Community Member

                  For completeness sake you may  also want to cover "TOP" type on path and anchored page items.

                   

                  Dirk

                  • 6. Re: how to get all page items from the document
                    suren_tringer Community Member

                    Hi all,

                     

                    i use the  following code  to get all pageitem and its path type .i am able to get all page item's UIDRef .but i am not able to get its path type.

                    please help me!

                     

                    for (int32 nPage = 0; nPage < numberOfPages; nPage++ )

                                {

                                    UIDList pageItemList(database);

                                    spread->GetItemsOnPage

                                    (

                                     nPage,

                                     &pageItemList,

                                     kFalse,

                                     kFalse

                                     );

                                   

                                    // Iterate the page items and save off the UIDs of frames.

                                    bool16 hasContent;

                                    int32 pageItemListLength = pageItemList.Length();

                                    for (int32 j = 0; j < pageItemListLength; j++ )

                                    {

                                        UIDRef pageItemRef = pageItemList.GetRef(j);

                                        //InterfacePtr<IGraphicFrameData> graphicFrameData(pageItemRef, UseDefaultIID());

                                        //hasContent =graphicFrameData->IsGraphicFrame();

                                        InterfacePtr<IPathGeometry> pathGeometry(pageItemRef,UseDefaultIID());

                                        if (pathGeometry != nil)

                                        {

                                           

                                           

                                            PMPageItemType pathType = Utils<IPathUtils>()->WhichKindOfPageItem(pathGeometry); // issue ,this statement is not return the path type

                                            switch (pathType)

                                            {

                                                case kIsPoint:

                                                    break;

                                                case kIsLine:

                                                    break;

                                                case kIsSquare:

                                                    break;

                                                case kIsRectangle:

                                                    break;

                                                case kIsCircle:

                                                    break;

                                                case kIsOval:

                                                    break;

                                                case kIsPoly:

                                                    break;

                                                case kIsPath:

                                                    break;

                                                case kIsCompoundPath:

                                                    break;

                                                default:

                                                    break;

                                            }

                                        }

                                

                                    }

                    • 7. Re: how to get all page items from the document
                      mfreitag Community Member

                      Hi,

                       

                      did you try it with IPageItemTypeUtils instead of IPathUtils?

                       

                      Markus

                      • 8. Re: how to get all page items from the document
                        Suraba Community Member

                        You also can iterate all of UIDs in doc’s database.

                         

                        Have a look on IDataBase.h and there are several examples in the SDK.