1 Reply Latest reply on Feb 20, 2014 4:18 PM by Ricardo Av-Oracle

    How to wait until setPage(number) is finished

    user2238254

      SR 3-8311228061

      When calling getStrings, found I need to iterate the pages of the doc/xls/etc

      However Autovue Support tells me that setPage() is asynchronous

      I asked how to wait until setPage() is complete, they suggested I post the question here


      Note, at the time its called the viewer (desktop version 20.2.2) is on the task tray, but not rendering the document

      Its only loaded to extract the text


      here is the blip of code

      for( curPage = 1; curPage <= pages; curPage++)

      {

      vueBean.setPage( curPage ); //its necessary to call setPage even for page 1

       

      //If setpage fails stop (per Daniel/Oracle)

      int thisPage = vueBean.getPage();

      if( curPage != thisPage )

      {

      //This message never shows up

      String msg = String.format("Pages[%d] thisPage[%d] curPage[%d] ", pages, thisPage, curPage);

      AdeptApplication.INSTANCE.publishEvent("file-event", msg,

      new SystemEvent(this.fileName, "GETTEXT_PAGEFAILED"));

      break;

      }



        • 1. Re: How to wait until setPage(number) is finished
          Ricardo Av-Oracle

          The code you have is to know whether changing pages succeeded or not, and unless you are trying to set a page number that is out of the page count it will always succeed

          So, yes, your test is the same as if (false)

          Now, page loading is done in an asynchronous manner

          1. you ensure that the page (the container for all the page artifacts) is created, synchronously

          2. the page content are streamed on another thread

          3. once the page is loaded, an event is sent VueEvent(VueEvent.FILEEVENT, VueEvent.ONPAGELOADED)

           

          So you should be able to query for info after you received the page loaded event

           

           

          Now, word documents are an special kind of documents, so you need to be aware of some specific issues.

          The same way ms-word does not know the total number of pages until the ENTIRE document is loaded, AutoVue will not be able to notify you either.

          And as Word, AutoVue allows you to display the pages that are already loaded, and you may query for some of its contents too.  BUT you can not query for page info when the page is been loaded (or obviously not yet loaded)

          The loading is a 2 phase one, part is done on the server (native code) and part is on the java side (display)

          So you will not be able to iterate

          for( curPage = 1; curPage <= pages; curPage++)

          simply because page count is not known.  You need to query doc info more than once.

          If page count = -1, you need to iterate for each page and then, test whether setPage() != getPage() and/or page count has been updated.