How to get the position of the scrollbar of a pdf within an iframe

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aman Puri

    How to get the position of the scrollbar of a pdf within an iframe

    Hi

    I have a requirment in which there is a pdf file which gets opened within html and there is a check box after the pdf file.. Now the requirment is that user needs to scroll down till the end of the PDF file and only then the checkbox shld get enabled (simlar to a licenes agreement).. I have included the pdf file within an iframe but i am not able to get the scroll position which should be the EOF, since the scroll is that of the PDF...

    how do i go abt achieveing this??? using anything will do jsp or javascript or even java.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    I'm not sure about the PDF, but you could use the scrollTop property of the iframe. I've not tried this, so it may not work, but it's worth a try.

    Comment

    • Aman Puri

      #3
      Actually i have already that but it doesnt work since the scroll which appears in the iframe is that of pdf...

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Could you not fix the size of the iframe so that it scrolls with the PDF, i.e. it's the same size or smaller than the PDF "window".

        Comment

        • Aman Puri

          #5
          I am not getting here what you are getting at, when i include the pdf in the Iframe the scroll which appears is that of the PDF, not of the iframe, if the PDF doesnt have a scroll it wont appear... I think you are telling me to include an iframe within and iframe, and try to set the size of the outer iframe to that of the pdf.. well i have tried that also and doesnt work :( .

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Say the PDF file is 1000px in height for one page. If you keep the iframe the same size or slightly smaller, that would mean that the iframe has a scrollbar (or the user can see the whole page).

            Now, one way you could get this working is to keep all pages in the PDF document as separate files and have Previous/Next buttons to load the files. Do you see how that could work?

            Acrobat does have its own version of JavaScript (see here), but I don't think you'll find a solution there. It'd involve changing the PDF document, I'm not sure if there's even a scroll event or any way to check it, and even if there is I don't think there's any possibility of interacting with the HTML page.

            Comment

            • Aman Puri

              #7
              Well what a bummer that was, actually the concept of you telling me abt previous and next buttons i already have implemented in my application, because this is a series of pdf files intended for a particular user, so after reading one file, they need to click on the next button to read the next file which is meant for them based on priorty, this has all been done, the only challenge right now is to somehow make sure that the user has actually read the file.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Checking again, maybe there is a way to interact, but it doesn't look simple and straightforward (something to do with viewState).

                Anyway, I've thought of a possible solution. Why not convert the PDF documents to Flash/SWF (free tools available) and then use SWFObject to interact with the Flash file. I think you should be able to get the underlying properties, e.g. see here.

                Comment

                • Aman Puri

                  #9
                  Thank having a look will get back to you, incase i still need help thanks a ton..

                  Comment

                  Working...