473,394 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Opening PDF at specified page

I have some js that looks like this:

fOpenPDFInNewWindow = function(url,page) {
var page = page || 1;
newPDF = window.open(url+"#pagemode=bookmarks&page="+page,
"location=no,menubar=no;toolbar=no,scrollbars=no,w idth="+800+",height="+600+"\"");
}

and some HTML that looks like this:

<a href="#"
onclick="fOpenPDFInNewWindow('http://www.domain.com/test.pdf',5); return
false;">test link</a>

In my testing the PDF always opens at the specified page yet the client
insists that in her testing it only ever opens at page 1. I thought that
this would be pretty straightforward but I'm stumped as to why it should
behave differently. The client is using IE 6.

Andrew Poulos
Apr 24 '06 #1
9 3066
Andrew Poulos wrote:
I have some js that looks like this:

fOpenPDFInNewWindow = function(url,page) {
var page = page || 1;
newPDF = window.open(url+"#pagemode=bookmarks&page="+page,
"location=no,menubar=no;toolbar=no,scrollbars=no,w idth="+800+",height="+600+"\""); ^ }
Eeek.

var newPDF;

function fOpenPDFInNewWindow(url,page) {
return (newPDF =
window.open(url
+ "#pagemode=bookmarks&page=" + (page || 1)
+ "scrollbars=yes,width=800,height=600"));
}
and some HTML that looks like this:

<a href="#"
onclick="fOpenPDFInNewWindow('http://www.domain.com/test.pdf',5); return
false;">test link</a>
Eeek 2. What about popup blockers, and what about absent script support?

<a href="http://www.domain.com/test.pdf"
onclick="return !fOpenPDFInNewWindow(this.href, 5);"Show PDF document</a> In my testing the PDF always opens at the specified page yet the client
insists that in her testing it only ever opens at page 1. I thought that
this would be pretty straightforward but I'm stumped as to why it should
behave differently. The client is using IE 6.


The client is not using only IE 6. They are also using either the Adobe
Reader plugin (or an equivalent) or the standalone Adobe Reader (or an
equivalent). Whether anchors within the PDF document are followed when
referred to as URI depends on both the browser and the used viewer
application. Older viewer plugins tend not to support anchors. And
external viewer plugins tend to not getting anything but the filename
from the browser, which downloads the resource to a file on the local
filesystem (temporary directory) first, and then opens the external
viewer with that file.

Probably one of the former is the case with your client, while you are using
more a recent viewer as a plugin. Check incompatibilities there; although
your code is unnecessarily complicated, error-prone and does not degrade
gracefully, certainly the main reason of the problem is not the code
because your client said that the PDF document is displayed.
PointedEars
--
When you have eliminated all which is impossible, then
whatever remains, however improbable, must be the truth.
-- Sherlock Holmes
Apr 24 '06 #2
Andrew Poulos wrote:
I have some js that looks like this:

fOpenPDFInNewWindow = function(url,page) {
var page = page || 1;
newPDF = window.open(url+"#pagemode=bookmarks&page="+page,
"location=no,menubar=no;toolbar=no,scrollbars=no,w idth="+800+",height="+600+"\""); ^ }
Eeek.

var newPDF;

function fOpenPDFInNewWindow(url,page) {
return (newPDF =
window.open(url
+ "#pagemode=bookmarks&page=" + (page || 1)
+ "scrollbars=yes,width=800,height=600"));
}
and some HTML that looks like this:

<a href="#"
onclick="fOpenPDFInNewWindow('http://www.domain.com/test.pdf',5); return
false;">test link</a>
Eeek 2. What about popup blockers, and what about absent script support?

<a href="http://www.domain.com/test.pdf"
onclick="return !fOpenPDFInNewWindow(this.href, 5);"Show PDF document</a> In my testing the PDF always opens at the specified page yet the client
insists that in her testing it only ever opens at page 1. I thought that
this would be pretty straightforward but I'm stumped as to why it should
behave differently. The client is using IE 6.


The client is not using only IE 6. They are also using either the Adobe
Reader plugin (or an equivalent) or the standalone Adobe Reader (or an
equivalent). Whether anchors within the PDF document are followed when
referred to as URI depends on both the browser and the used viewer
application. Older viewer plugins tend not to support anchors. And
external viewers tend to not getting anything but the filename from the
browser, which downloads the resource to a file on the local filesystem
(temporary directory) first, and then opens the external viewer with that
file.

Probably one of the former is the case with your client, while you are using
more a recent viewer as a plugin. Check incompatibilities there; although
your code is unnecessarily complicated, error-prone and does not degrade
gracefully, certainly the main reason of the problem is not the code
because your client said that the PDF document is displayed.
PointedEars
--
When you have eliminated all which is impossible, then
whatever remains, however improbable, must be the truth.
-- Sherlock Holmes
Apr 24 '06 #3
Thomas 'PointedEars' Lahn wrote:
In my testing the PDF always opens at the specified page yet the client
insists that in her testing it only ever opens at page 1. I thought that
this would be pretty straightforward but I'm stumped as to why it should
behave differently. The client is using IE 6.


The client is not using only IE 6. They are also using either the Adobe
Reader plugin (or an equivalent) or the standalone Adobe Reader (or an
equivalent). Whether anchors within the PDF document are followed when
referred to as URI depends on both the browser and the used viewer
application. Older viewer plugins tend not to support anchors. And
external viewers tend to not getting anything but the filename from the
browser, which downloads the resource to a file on the local filesystem
(temporary directory) first, and then opens the external viewer with that
file.

Probably one of the former is the case with your client, while you are using
more a recent viewer as a plugin. Check incompatibilities there; although
your code is unnecessarily complicated, error-prone and does not degrade
gracefully, certainly the main reason of the problem is not the code
because your client said that the PDF document is displayed.


Thanks for the help (lesson?) in JavaScript. Unfortunately I think the
problem is more "serious". I can get a PDF to open at a specified page
from my computer. I have a second computer on which I have loaded IE 6,
with the latest updates, and Acrobat 7.07, which I downloaded today,
installed.

On the second computer any content in the query string of the URL gets
ignored. That is, I cannot set pagemode, destination, page...

Of course it works correctly (or appears to) in FF 1.5. I wonder if it's
some new security feature of IE/Windows?

Andrew Poulos


Apr 25 '06 #4
VK

Andrew Poulos wrote:
I wonder if it's
some new security feature of IE/Windows?


Yes, it is. Windows XP SP2 activates very harsh popup blocker by
default. It is strange that your solution is still working for anyone:
either your users are not Windows ones, or the majority is using
outdated Windows platforms (98, 2000, ME).

If SP2 is installed, userAgent string contains "SV1", and it means 70%
chance that you cannot open new windows by script (highly generous 30%
left for customized settings).

I believe several months ago in this very group with a similar problem
I suggested you to start migration on popupless solution asap. You
ignored my advise as I can tell. :-(

;-)

Apr 25 '06 #5
VK wrote:
Andrew Poulos wrote:
I wonder if it's some new security feature of IE/Windows?


Yes, it is. Windows XP SP2 activates very harsh popup blocker by
default. It is strange that your solution is still working for anyone:
either your users are not Windows ones, or the majority is using
outdated Windows platforms (98, 2000, ME).

If SP2 is installed, userAgent string contains "SV1", and it means 70%
chance that you cannot open new windows by script (highly generous 30%
left for customized settings).

I believe several months ago in this very group with a similar problem
I suggested you to start migration on popupless solution asap. You
ignored my advise as I can tell. :-(


No, I think you've misunderstood my question. A URL that points to a PDF
*is* opened with JavaScript when a user clicks a link. Popup blocking is
not the issue here. (Pointed Ears showed me how to make it less
"error-prone" and how to degrade it gracefully for users with JavaScript
turned off.)

The problem is that the PDF always opens on page 1 irrespective of the
query string contents. The Adobe site says that #page=5 should open the
PDF at page 5 (it does with FF and IE 6 on my computer) but it opens at
page 1 with IE 6 on other computers.

Even if I put the URL plus query string into the A's href it still opens
at page 1. The display URL in the address bar is correct but the page is
not.

My lament about security features was about some new(?) one added to PDF
display.

Andrew Poulos
Apr 25 '06 #6
VK

Andrew Poulos wrote:
No, I think you've misunderstood my question.
Sorry.
The problem is that the PDF always opens on page 1 irrespective of the
query string contents. The Adobe site says that #page=5 should open the
PDF at page 5 (it does with FF and IE 6 on my computer) but it opens at
page 1 with IE 6 on other computers.


I'm not aware of it. You should look at MSDN, but before you should
check is it a problem with a *newer* viewer or with an *outdated*
viewer which simply doesn't support this feature. Sometimes people
reinstall their beloved utils from CD's kept for years.

Apr 25 '06 #7
Andrew Poulos wrote:
Thanks for the help (lesson?) in JavaScript.
You are welcome. You may see it as a lesson if you think you have learned
something from it :)
Unfortunately I think the problem is more "serious". I can get a PDF to
open at a specified page from my computer. I have a second computer on
which I have loaded IE 6, with the latest updates, and Acrobat 7.07,
which I downloaded today, installed.

On the second computer any content in the query string of the URL gets
ignored. That is, I cannot set pagemode, destination, page...
Hmmm.
Of course it works correctly (or appears to) in FF 1.5. I wonder if it's
some new security feature of IE/Windows?


Unlikely. It is rather an incompatibility between IE and the plugin. In
my previous job at the IBM Help Desk, we encountered strange problems with
the Adobe Reader plugin when IE was updated (with security patches), such
as that no PDF documents were displayed anymore. Reinstalling Adobe Reader
(any version above 5.0) fixed these problems. Maybe that works for you,
too.

But reviewing your code a second time, this line could be a problem:

newPDF = window.open(url+"#pagemode=bookmarks&page="+page,

Either "&page="+page is part of the query component of the URI, or it is
part of its fragment component (since you want to show a specific page of
the PDF document, the latter is more likely). If the former, it must be
placed before the first "#" (but after the first "?") and can be used as
is (provided that `page' is a decimal number); if the latter, it must be
placed after the first "#" and must be encoded with encodeURIComponent(),
especially the "&". See also RFC3986 "Uniform Resource Identifier (URI):
Generic Syntax", section 3 et seqq.
HTH

PointedEars
--
The name of God: J-E-H-O-V-A. "J"...argh!
[crashes right through the "J"-slab, hanging over a hidden abyss
....eventually pulls himself out of the trap] Oh boy, what a fool
I am???!!! In Latin, Jehova starts with an "I"! -- Indiana Jones
Apr 25 '06 #8
But reviewing your code a second time, this line could be a problem:

newPDF = window.open(url+"#pagemode=bookmarks&page="+page,

Either "&page="+page is part of the query component of the URI, or it is
part of its fragment component (since you want to show a specific page of
the PDF document, the latter is more likely). If the former, it must be
placed before the first "#" (but after the first "?") and can be used as
is (provided that `page' is a decimal number); if the latter, it must be
placed after the first "#" and must be encoded with encodeURIComponent(),
especially the "&". See also RFC3986 "Uniform Resource Identifier (URI):
Generic Syntax", section 3 et seqq.

I tried a number of possible permutations with no success. I'm running
out of time so I converted the PDF to HTML and used anchors. This will
give me more time to play with it before the next PDF I have to try to
link to.

Additionally, page 8 of this doc:
<url:
http://partners.adobe.com/public/dev...Parameters.pdf

gives examples one of which matches my usage.

This page:
<url: http://www.adobe.com/support/techdocs/317300.html >
says "If you use URLs other than HTTP and HTTPS, such as server
locations (\\servername\folder), then set the link to open to a set
destination using the procedure in the following section" but I don't
quite understand it. Do they mean that other than HTTP of HTTPS you
should use destinations rather than page numbers?

Andrew Poulos
Apr 26 '06 #9
Andrew Poulos wrote:

Please provide attribution of quoted material. Your Thunderbird does this
automatically by default, in a configurable way. Don't remove that.
But reviewing your code a second time, this line could be a problem:

newPDF = window.open(url+"#pagemode=bookmarks&page="+page,

Either "&page="+page is part of the query component of the URI, or it is
part of its fragment component (since you want to show a specific page of
the PDF document, the latter is more likely). If the former, it must be
placed before the first "#" (but after the first "?") and can be used as
is (provided that `page' is a decimal number); if the latter, it must be
placed after the first "#" and must be encoded with encodeURIComponent(),
especially the "&". See also RFC3986 "Uniform Resource Identifier (URI):
Generic Syntax", section 3 et seqq.


I tried a number of possible permutations with no success. I'm running
out of time so I converted the PDF to HTML and used anchors. This will
give me more time to play with it before the next PDF I have to try to
link to.

Additionally, page 8 of this doc:
<url:

http://partners.adobe.com/public/dev...Parameters.pdf
>

gives examples one of which matches my usage.


Well, if Adobe wants to redefine URIs, that is their prerogative; however,
they should not expect this to work in other user agents than Adobe Reader.
And neither should you.
This page:
<url: http://www.adobe.com/support/techdocs/317300.html >
says "If you use URLs other than HTTP and HTTPS, such as server
locations (\\servername\folder), then set the link to open to a set
destination using the procedure in the following section" but I don't
quite understand it.
Obviously they have not really a clue what they are talking about. "Server
locations", more precisely UNC (Uniform Naming Convention) paths, are not
URLs (which are a subset of URIs). However, such resources also can be
referred to by a "file:" URI: file://server/share.
Do they mean that other than HTTP of HTTPS you should use destinations
rather than page numbers?


It would appear that they mean to use the destination like an anchor in an
HTML document instead of the page number if either the reference is not an
URI, or the protocol component of the URI is not http(s).

However, maybe you have better luck defining a destination for each page of
the PDF document.

I do not think further discussion about this issue is on topic here.
PointedEars
Apr 26 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
0
by: Sarah | last post by:
Hi, I'm opening a MS Word file through c# // Open the specified document DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory); FileInfo fi = di.GetFiles("myTest.doc"); if...
4
by: OutdoorGuy | last post by:
Greetings, I am receiving the following error message when I try to run a sample application that I've created: "The Microsoft Jet database engine cannot open the file 'C:\MYDATA\Sports.mdb'....
0
by: jandry | last post by:
I got a strange PC on 2 PCs. They have Windows 200 SP4, Visual Studio 2003 and Framework 1.1. We are doing asp.net with vb langage. When I try to open design, even after recompiling solution, I...
1
by: Kevin O`Brien | last post by:
I was reading my new asp.net book last night and thought I'd give mobile devices a go. I use Web Matrix, however when I went to create a new mobile page this morning, it displayed a dialog box...
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
11
by: emailus | last post by:
I am webmaster for the domain <www.alpha1.org.au>. Not being an expert in html, I take advantage of my domain Registrant's web building tool, 'Instant Website'. This tool is provided as part of...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
1
by: developing | last post by:
Hey all, I am using the FileUpload control in ASP.NET to upload a file. Its working jsut fine. I need to implement it so that when you click 'Browse', the dialog opens up in a specified...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.