6 Replies Latest reply: Jun 29, 2009 5:10 AM by anaghad RSS

    How to get PDF page orientation using acrobat api?

    anaghad Community Member

      Hi,

       

      Is there an acrobat API to judge the PDF Page orientation (i.e. Portrait or Landscape)? Also, i need to know the basis of conversion of the word quads between portrait & landscape orientation.

      Currently, all i could find was PDPageGetRotate method which gives the rotation value, but in this case word quads will not get changed, am i correct?

      I clearly need to demarcate between the rotation and orientation of a pagei n PDF.

       

      Please help me with the above questions.

       

      Thanks.

        • 1. Re: How to get PDF page orientation using acrobat api?
          lrosenth Adobe Employee

          PDF pages don't have an orientation.  They simply have a MediaBox size and (optionally) a rotation.

          • 2. Re: How to get PDF page orientation using acrobat api?
            joeln3 Community Member

            You can guess the orientation with the MediaBox.

             

            e.g. MediaBox [ 0 0 595 800] with Orientation 0 is a landscape.

            • 3. Re: How to get PDF page orientation using acrobat api?
              anaghad Community Member

              Hi,

               

              Joe, could you please explain me the approach you've mentioned on getting the orientation using media box?

              The acrobat api PDPageGetMediaBox returns an ASFixedRect (in userspace) which gives us the left-right-top-bottom of the page. How do we judge here the orientation of a page?

               

              Also, I specifically want to know how to get the orientation (NOT rotation) of a page? In other words, I clearly want to demarcate between the rotation and orientation of a page. This is because, I found out that quads of the words changes when the orientation is changed, but not when the rotation is changed. Am I correct? Based on the change in word quad, I want to code out the functionality for drawing annots. That's why I need to know the exact word quad's which either remains uniform across the orientations and rotations or if there is any way to transfor those word quads when orientation is changed?

               

              Appreciate everyone's replies.

               

              Thanks!

              • 4. Re: How to get PDF page orientation using acrobat api?
                joeln3 Community Member

                Hi anaghad,

                 

                Orientation is either landscape or portrait. Retrieving the MediaBox you can 'guess' the orientation. When top/bottom is larger than right/left it means that the orientation is landscape. Otherwise it's portrait.

                Unfortunatelly some application (or plug-ins) change the MediaBox instead using the Rotation parameter which is stored for each page in the PDF. So you can never be sure that the orientation will be correct. You just can 'guess' the orientation of the media. But in most of the case you can have the orientation with the MediaBox.

                 

                Regards,

                Joe

                • 5. Re: How to get PDF page orientation using acrobat api?
                  anaghad Community Member

                  Hi Joe,

                   

                  Well, the PDPageGetMediaBox method returns me the same ASFixedRect value for both 'portrait' and 'landscape' orientation of a PDF. Here are the value I get for my PDF in both orientations:-

                  left  - 0
                  top - 51904512
                  right - 40108032

                  bottom - 0

                   

                  The PDPageGetRotate method returns '0' and '90' for portrait and landscape respectively. But, this is not what I need. I need to find out the orientation of PDF after it opnes. Can you also tell me how the X & Y axes are positioned in these orientations?

                   

                   

                  • 6. Re: How to get PDF page orientation using acrobat api?
                    joeln3 Community Member

                    Hi anaghad,

                     

                    You can deduce the orientation. Actually the value of the ASFixedRect are [ lower-left x, lower-left y, upper-right x, upper-right y ]. To have the correct value use the ASFixedToInt32 and you will be able to find the orientation of the Media with the length and heigth.

                     

                    Use the rotation to change the orientation.

                     

                    E.g. MediaBox [0 0 100 400] is portrait. If you have a rotation of 90° in addition it's landscape.

                     

                    Regards,

                    Joe