20 Replies Latest reply: May 22, 2012 5:13 AM by MrRamrod RSS

    How to rotate the page view using cos method

    arvindg007 Community Member

      Hi,

       

      On rotating the page using cos method (as PDPageSetRotate is n’t avialble for reader ), page content gets rotated but display size pf page is not getting changed and because of this it is not showing full content of the page.  Basically I want to rotate the view as we can do by pressing (Shift + Ctrl+ Plus) in standalone Acrobat reader.

       

      I am using following code to achive this but it is not changing the display size of page.

       

       

       

       

       

       

      for(int iPg=0; iPg<nNumPage; iPg++)

      {

       

       

      // acquire each page

      pdPage = PDDocAcquirePage(pdDoc, iPg);

      CosObj pageCos = PDPageGetCosObj(pdPage);

       

       

      newRotObj = CosNewInteger (cosDoc, false, pdRotate90 );

      CosDictPut (pageCos, ASAtomFromString(

      "Rotate"), newRotObj);

      PDPageRelease (pdPage);

      }

       

      So please let me know the fix of the issue.

       

      Regards,

      Arvind

        • 1. Re: How to rotate the page view using cos method
          joeln3 Community Member

          Hi,

           

          The easier way is to simulate the click on the button in the Acrobat window using the JavaScript function ExecuteMenuItem(). If you have the name of the rotation menu item it will be easier. (the name is : RotateCW)

           

          Regards,

          Joe

          • 2. Re: How to rotate the page view using cos method
            arvindg007 Community Member

            Hi Joe,

             

            Thanks for your suggestion !

            And  I tried AVMenuItemExecute method but this is not working for me. I think this method works for active doc only. And I didn't find any api to make my doc as active doc.

             

            Regards,

            Arvind

            • 3. Re: How to rotate the page view using cos method
              joeln3 Community Member

              hi Arvind,

               

              I have some question :

              • Is the document open in an Acrobat window?
              • What is the result when you use the AVMenuItemIsEnabled? Is the MenuItem enable?

               

              For the window you can use the AVWindowBecomeKey to make it the key window (note that the window has to be visible).

               

              Regards,

              Joe

              • 4. Re: How to rotate the page view using cos method
                arvindg007 Community Member

                 

                Hi Joe,

                 

                 

                AVMenuItemIsEnabled method returns false in my case. I don't know why it is coming like that?. But when I press (Shift+Ctrl+plus), it rotates the page so it means in actual rotate menu is enabled . Is some thing wrong in my code  (see below)

                 

                AVMenubar theMB = AVAppGetMenubar();

                AVMenuItem rotateMenu = AVMenubarAcquireMenuItemByName(theMB,

                 

                 

                "RotateCW");

                 

                 

                 

                 

                if

                (AVMenuItemIsEnabled (rotateMenu))

                {

                AVWindowBecomeKey ( AVDocGetAVWindow(avDoc));

                 

                 

                 

                 

                AVMenuItemExecute (rotateMenu);

                }

                 

                Regards,

                Arvind

                • 5. Re: How to rotate the page view using cos method
                  joeln3 Community Member

                  Hi,

                   

                  My mistake. Actually you can't use "RotateCW" but you can use "RotatePages". Using RotatePages a popup appears.

                  What is exactly your need?

                   

                  Regards,

                  Joël

                  • 6. Re: How to rotate the page view using cos method
                    arvindg007 Community Member

                    Hi Joe,

                     

                    Actually in my application, I have to create my own Rotate View button. And using that button I have to simulate the same thing which we can do using RotateCW or RotateCCW in standalone reader.

                     

                    Since PDPageSetRotate method is not available for reader plug-in and that's why I tried to rotate the view using cos method but that rotates page content but don't change the display size of paper and that's the issue I am facing.

                     

                    I tried Rotatepages also but I am getting NULL value for this item.

                     

                    Regards,

                    Arvind

                    • 7. Re: How to rotate the page view using cos method
                      joeln3 Community Member

                      And using "RotatePages". It's case sensitive.

                      • 8. Re: How to rotate the page view using cos method
                        arvindg007 Community Member

                        Yes , I used "RotatePages" only but I am getting NULL value for that. But if it works also then pop-up issue will be there for me.

                         

                        Regards,

                        Arvind

                        • 9. Re: How to rotate the page view using cos method
                          joeln3 Community Member

                          It's is strange. How did you open the document in Acrobat? I mean which method are you using?

                          • 10. Re: How to rotate the page view using cos method
                            MrRamrod Community Member

                            Menus will not be available if the viewer is being run as an embedded window (inside another application, for example)

                            That would explain why executing menu items will not work.

                            • 11. Re: How to rotate the page view using cos method
                              arvindg007 Community Member

                              I open the document using Active-X method named  LoadFile(fileName) which is available for reader.

                              • 12. Re: How to rotate the page view using cos method
                                joeln3 Community Member

                                As said if the menu bar is not displayed you can't use it. But if the buttons are displayed you can try to execute the button "RotateCW".

                                • 13. Re: How to rotate the page view using cos method
                                  MrRamrod Community Member

                                  instead of executing a menu/toolbutton (which arent available it would seem), is there an API call which performs the required operation

                                  i.e. is there an API method (or set of methods) that will rotate the view instead of the page?

                                  • 14. Re: How to rotate the page view using cos method
                                    arvindg007 Community Member

                                    Tool button RotateCW is also not working for me. As AVToolButtonIsEnabled(myToolButton) returns false for me (see below code that I used for this ).

                                     

                                        const char * toolBarName = "PageDisplay";

                                        AVToolBar myToolBar = AVAppGetToolBarByName(toolBarName);

                                        AVToolButton myToolButton = AVToolBarGetButtonByName(myToolBar, ASAtomFromString("RotateCW"));

                                        if(AVToolButtonIsEnabled(myToolButton))

                                            AVToolButtonExecute(myToolButton);

                                     

                                     

                                    This is very strange, because I can see the same tool button in the display and it works fine also if you press it.

                                     

                                    Regards,

                                    Arvind

                                    • 15. Re: How to rotate the page view using cos method
                                      arvindg007 Community Member

                                      Hi,

                                       

                                      Any idea...how we can rotate page using code(i.e plug-in api, JS api or thru Cos method)  for acrobat reader ? RotatePage thru  cos method rotate the page but it doesn't show full content of page .

                                       

                                      Regards,

                                      Arvind

                                      • 16. Re: How to rotate the page view using cos method
                                        lrosenth Adobe Employee

                                        I don’t understand when you say “it doesn’t show full contents of the page”.

                                         

                                        If you rotate the MediaBox and you rotate the content, then it will all show.

                                        • 17. Re: How to rotate the page view using cos method
                                          arvindg007 Community Member

                                          Hi Irosenth,

                                           

                                           

                                           

                                          For Reader PDPageSetMediaBox is not available. So I tried following code to rotate the media Box but it doesn’t work.

                                           

                                           

                                           

                                           

                                           

                                          PDDoc pdDoc = AVDocGetPDDoc(avDoc);

                                           

                                          int nNumPage = PDDocGetNumPages(pdDoc);

                                           

                                          CosDoc cosDoc = PDDocGetCosDoc(pdDoc);

                                           

                                          PDPage pdPage;

                                           

                                          for(int iPg=0; iPg<nNumPage; iPg++)

                                           

                                              {   

                                           

                                          pdPage = PDDocAcquirePage(pdDoc, iPg);

                                           

                                                         CosObj pageCos = PDPageGetCosObj(pdPage);

                                           

                                                         CosObj rectangle;

                                           

                                          rectangle = CosDictGet(pageCos, ASAtomFromString("MediaBox"));

                                           

                                          CosObj left = CosArrayGet (rectangle, 0L);

                                           

                                                       CosObj bottom = CosArrayGet (rectangle, 1L);

                                           

                                                       CosObj right = CosArrayGet (rectangle, 2L);

                                           

                                                      CosObj top = CosArrayGet (rectangle, 3L);

                                           

                                                     

                                           

                                                    double vl = ASFixedToFloat(CosFixedValue (left));

                                           

                                                    double vr = ASFixedToFloat(CosFixedValue (right));

                                           

                                                    double vt = ASFixedToFloat(CosFixedValue (top));

                                           

                                                  double vb = ASFixedToFloat(CosFixedValue (bottom));

                                           

                                           

                                           

                                                  double w = vr-vl;

                                           

                                                  double h = vt-vb;

                                           

                                                  vr = vl+ h;

                                           

                                                  vt = vb+w;

                                           

                                           

                                           

                                                  CosObj newR = CosNewFixed (cosDoc, false, ASFloatToFixed(vr));

                                           

                                                  CosObj newT = CosNewFixed (cosDoc, false, ASFloatToFixed(vt));

                                           

                                                                         

                                           

                                                 CosObj newRectangle;

                                           

                                                  newRectangle = CosNewArray (cosDoc, false, 4L);

                                           

                                                  CosArrayPut (newRectangle , 0L, left);

                                           

                                                  CosArrayPut (newRectangle , 1L, bottom);

                                           

                                                  CosArrayPut (newRectangle , 2L, newR);

                                           

                                                  CosArrayPut (newRectangle , 3L, newT);

                                           

                                                  CosDictPut (pageCos, ASAtomFromString("MediaBox"),newRectangle)

                                           

                                                                         

                                           

                                                 PDPageRelease (pdPage);

                                           

                                          }

                                           

                                           

                                           

                                          Any Idea what else I need to do to make it work ?. I have even called following code after above code.

                                           

                                            AVWindow win = AVDocGetAVWindow(avDoc);

                                           

                                            AVWindowDrawNow(win);

                                           

                                          AVPageView pageView = AVDocGetPageView (avDoc);

                                           

                                          AVPageViewDrawNow (pageView);

                                           

                                               

                                           

                                          But this also doesn’t update media box.

                                           

                                           

                                           

                                          Please let me know your view on this.

                                           

                                           

                                           

                                          Thanks in advance

                                           

                                          Arvind

                                          • 18. Re: How to rotate the page view using cos method
                                            lrosenth Adobe Employee

                                            That code will change the Cos objects, but won't force Reader to re-render the page…because it's Reader, and you shouldn't be modifying things in Reader.

                                            • 19. Re: How to rotate the page view using cos method
                                              arvindg007 Community Member

                                              Then how to rotate page/view in Reader thru code ?

                                              • 20. Re: How to rotate the page view using cos method
                                                MrRamrod Community Member

                                                Another way of approaching this.

                                                 

                                                If we cannot modify the page, can we rotate the camera?