-
That would require counting the pages in the PDF. There are, or at least were (I found instructions for Acrobat 7) methods for that in javascript, but that would probably only work for PDF's on the user's hard drive, and only if they have Acrobat 7 Pro installed). Assuming all that, do it remotely and security would be an issue. If it's not your computer, most browsers will not allow you to do that without an ssl, perhaps more certification. PHP can perhaps be used. I just Googled it and there appears to be a method for counting pages in PDF. In any case you would have to deal only with PDF's that have a standard page height.
Try out what I'm playing with in post #9. It's by no means a finished work. You need to use Acrobat's scrollbar to scroll through the pages. But at least you get to see all pages. The document has no scrollbar.
In most cases though, with PDF you just link them to the .PDF file. They can then view it online or off, and resize and scroll through it however they like.
Remember, you have no way of knowing what version of Acrobat or even if it is Acrobat that the user has to view PDF, or if they even have a viewer, or if they do, if it's even configured to work with their browser.
-
I'm testing the method using PHP to count the number of pages. It looks like it may be workable. Do you have PHP?
-
Counting the pages - that makes perfect sense.
I'm ok with either PHP or ASP.
all the PDF pages will be standard A4 size (h: 29.7cm * w: 21 cm).
-
1 Attachment(s)
Well, it's working, more or less. There are a number of issues. I'm not sure I can recall them all here, these are the most important:
- In Firefox when the page first loads with the first PDF on it, and each time a PDF is loaded via AJAX, the ability to use the home/end, up/down arrow, pgup/pgdn keys, and the scrollwheel are lost unless the tab/window loses focus and regains it. Using javascript (window.blur()/window.focus()) for this doesn't help. One may still scroll by dragging the window's/tab's scrollbar.
- Even after that, one must click somewhere on the page other than on the PDF to activate use of these keys and the wheel. This part is true in other browsers. Click on the PDF and these functions are lost again until you click off of it. I haven't tested it, but covering the PDF with an almost transparent div or a transparent .gif might help a little here.
- In IE there still are occasional instances where the PDF just doesn't show up. To fix this I've added the src param to the object tags and created a redundant loading of the imported tag (as mentioned before). Both of these strategies seem to help, but haven't eliminated the problem completely.
Here's a demo:
Attachment 3523
Unzip it to a separate folder on your PHP host or PHP local server. The way the PHP code is written, the PDF files need to be in the same folder as the pages.php file. Easiest to just keep everything in the same folder. If you choose though, you can edit the PHP file and/or move things around. Just be careful not to break the PHP file's ability to find the PDF files. I've used parameters to make the PDF's appear without the Acrobat toolbar, bookmark menu, or scrollbar. Doing so helped in removing some browser's (notably Opera) artifacts in the rendering of the Acrobat chrome and left more real estate for the actual PDF. If you change that, tweaks to the dimensions and/or how the height is calculated may be required. The main page is:
1234_ajax_4.htm
On it you will see:
Code:
. . . margin-left: 1em;
position: relative;
top: 2em;
}
#target object {
width: 600px; /* set object width here */
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($){
var pageHeight = 780, // set height for one page here
pagination = 65, // amount to add per page if more than one page
t = $('#target'), count = 0, h;
function sizeIt(pages){
pages = typeof . . .
These should be pretty self explanatory. I think however that my 1234_old.pdf file is a little non-standard. So if not using it, you can probably just do:
Code:
var pageHeight = 845, // set height for one page here
pagination = 0, // amount to add per page if more than one page
In any case, the height you use in the script needs to be worked out proportionally to the width you set in the style section. If more than one page, pageHeight is added to pagination and the sum is multiplied by the number of pages. If a single page, pageHeight is used alone.
-
Oh, and I just came across these:
http://flexpaper.devaldi.com/
and:
http://www.swftools.org/
Both look very good to me. Using Flash would eliminate many of the problems mentioned in my previous post.
Also:
http://www.axmag.com/
Not as sure about that last one.
-
Thank you so much for your time and good effort. Your script is just what i was after. The links are also very useful.
If you can derive at least a fraction of the benefit from the token donation i've just paypal-ed you, then all the better.
:D
-
Thanks, I was playing with this idea a bit further though.
It seems that there's code (to prevent a system and/or browser crash) in Acrobat for only allowing X amount of memory for the display of PDF. I loaded a 410 page PDF which made moderate use of graphics into my viewer, it only would display fully up to page 42 regardless of the browser. You can toggle between scrolling being on the page or the PDF like I mentioned. But you couldn't see much below page 42 without scrolling the PDF. Without a scrollbar this can only be done with the mouse wheel and/or navigation keys.
At the same time, the page counter still worked. So there was a lot of blank and/or (depending upon the browser) garbage space below the last rendered page.
Even with a large PDF, if it's all text, this might not be a problem. There would still ultimately be a limit to how many pages could be displayed in this manner.
It probably depends upon how many bytes are in the PDF. The one I tried with was 6,140,343 bytes (5,997 k).
If there's even moderate use of images in a file with so many pages, one would be better off with some variation on my one page at a time version, or with one or a combination of two or more of the Flash approaches. An advantage with Flash is that the content can be buffered and streamed, allowing the user to begin viewing/reading before the entire document has downloaded.
Alternatively, we may be able to determine the cutoff for bytes (this could vary by computer though - available memory), measure the file size in PHP and then determine how to display the PDF from there. This assumes it's a byte cutoff. It may actually relate directly to the number of pages. If so, we could use that.