2 Replies Latest reply on Apr 6, 2010 11:22 AM by EliezerReis

    Type of PageItem element

    EliezerReis Level 1

      On my document I have for example 20 page itens, some of them could be ovals, textframes, graphic and so on. How can I check the type of page item?


      For example:


      for (int i=0; i< document.countPageItems();i++) {

           PageItem item = document.getAllChildPageItems()[i];

           TextFrame frame = TextFrameHelper.narrow(item); //Here, how can i know the exact type of my item?


        • 1. Re: Type of PageItem element
          Bart Devos Level 1

          pi.getObjectSpecifier() where "pi" is the pageitem object gives you a specifier string. With some regex magic, you can strip-out the appropriate objecttype.


          Hope this helps!


          Bart Devos

          1 person found this helpful
          • 2. Re: Type of PageItem element
            EliezerReis Level 1

            It works, but  I discovered that I can use the method _is_a. Each helper (ImageHelper, TextFrameHelper and etc) has a static method id() so, I can do something like this:


            for (Graphic graph : page.getAllGraphics()) {
             //check if graphic is a Image
             if (graph._is_a(ImageHelper.id())) {
             //check if graphic is a Polygon
             if (graph._is_a(PolygonHelper.id())) {



            Thanks a lot