473,683 Members | 3,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Opening PDF at specified page

I have some js that looks like this:

fOpenPDFInNewWi ndow = function(url,pa ge) {
var page = page || 1;
newPDF = window.open(url +"#pagemode=boo kmarks&page="+p age,
"location=no,me nubar=no;toolba r=no,scrollbars =no,width="+800 +",height="+600 +"\"");
}

and some HTML that looks like this:

<a href="#"
onclick="fOpenP DFInNewWindow(' 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 3077
Andrew Poulos wrote:
I have some js that looks like this:

fOpenPDFInNewWi ndow = function(url,pa ge) {
var page = page || 1;
newPDF = window.open(url +"#pagemode=boo kmarks&page="+p age,
"location=no,me nubar=no;toolba r=no,scrollbars =no,width="+800 +",height="+600 +"\""); ^ }
Eeek.

var newPDF;

function fOpenPDFInNewWi ndow(url,page) {
return (newPDF =
window.open(url
+ "#pagemode=book marks&page=" + (page || 1)
+ "scrollbars=yes ,width=800,heig ht=600"));
}
and some HTML that looks like this:

<a href="#"
onclick="fOpenP DFInNewWindow(' 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 !fOpenPDFInNewW indow(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 incompatibiliti es 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:

fOpenPDFInNewWi ndow = function(url,pa ge) {
var page = page || 1;
newPDF = window.open(url +"#pagemode=boo kmarks&page="+p age,
"location=no,me nubar=no;toolba r=no,scrollbars =no,width="+800 +",height="+600 +"\""); ^ }
Eeek.

var newPDF;

function fOpenPDFInNewWi ndow(url,page) {
return (newPDF =
window.open(url
+ "#pagemode=book marks&page=" + (page || 1)
+ "scrollbars=yes ,width=800,heig ht=600"));
}
and some HTML that looks like this:

<a href="#"
onclick="fOpenP DFInNewWindow(' 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 !fOpenPDFInNewW indow(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 incompatibiliti es 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 incompatibiliti es 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=boo kmarks&page="+p age,

Either "&page="+pa ge 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 encodeURICompon ent(),
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=boo kmarks&page="+p age,

Either "&page="+pa ge 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 encodeURICompon ent(),
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\f older), 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=boo kmarks&page="+p age,

Either "&page="+pa ge 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 encodeURICompon ent(),
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\f older), 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
11077
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 window.open function? I would prefer not to create a separate HTML page. So far all I have is the basic var cwin = window.open('images/KJV-THANKS.gif', 'Thanks', 'width=243,height=420,'); cwin.focus();
0
948
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 (fi.Length <= 0) {
4
1311
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'. It is already opened exclusively by another user, or you need permission to view its data." I have verified that the database is not in use by another application.
0
1092
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 got the message "The class file 'page.aspx' specified as the codebehind for 'page.aspx.vb' could not be loaded. Make sure that the codebehind attribute in the page or control directive properly references an existing code behind file." My solution...
1
1431
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 with the message: "specified cast is not valid" The file seems to be getting created, but does not open. I get the same error when I try to open the file too.
2
3117
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, dataset.writexml works great (got the code from http://forums.devx.com/archive/index.php/t-57273.html ) The only question I have is, when Excel opens up, it isn't the view I would prefer. It opens as a read-only workbook, I would prefer as an
11
3521
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 the fee I pay for web hosting. 'Instant Website' provides the option of having your opening page as a Flash Page, which you'll see if you visit <www.alpha1.org.au>. Well, you'll see it if you visit from a Windows machine. For some reason, when...
34
5343
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 "<pyshell#10>", line 1, in <module> os.startfile("C:\Documents and Settings\Alex\My Documents\My
1
1403
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 directory. I dont know how to set this direcotory...please help.. how do i specify the opening base directory?
0
8568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8504
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8922
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8753
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8771
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7582
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
2934
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2195
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1921
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.