Link to a Bookmark in a PDF using ASP

I have to update the PDF in this page and it has a sidebar that links to various bookmarks in PDFs... but it is not working for some reasons.

This was made back in 2008, so is it possible that the code has changed since then?


Here is the link
AccurateDesignAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
What is not working?  Seems to work fine in chrome
0
AccurateDesignAuthor Commented:
if you click on Introduction, it should go to page 3 to the header Introduction, but it is not working for me

Also the red subtitles on the left don't seem to be working as well
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Ok, in your embed code try using below code. I am taking this from http://tools.ietf.org/html/rfc3778#page-3

#nameddest=Introduction or #page=3

Where you have

 <embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#" />

Open in new window


change to
 <embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#nameddest=Introduction" />

Open in new window

or
 <embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#page=3" />

Open in new window


If you are doing this dynamically, then you need to use below assuming your url ends like
http://mysite.com/index.asp?pdf=ICTC_HRGuide_Intro.pdf?bookmark=introduction

Notice I changed the # to a ?

 <embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#nameddest=<%=bookmark%>" />

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Edit to last code:

 <embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#nameddest=<%=request.querystring("bookmark")%>" />

Open in new window


However, to be super safe:
bookmark=request.querystring("bookmark")
if bookmark<>"" then
    bookmark=replace(bookmark,"'","")
    bookmark=replace(bookmark,"<","")
    bookmark=replace(bookmark,">","")
end if
 <embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#nameddest=<%=bookmark%>" />

Open in new window

0
AccurateDesignAuthor Commented:
nice! it works, but in Firefox for some reason the nameddest don't work but linking to a page it works... worst case I guess I could link to pages instead of anchors

Works in Firefox
http://myaccuratedev.com/clients/ICTC/08-088/pdfs/ICTC_HRGuide_Intro.pdf#page=3

Not working in Firefox
http://myaccuratedev.com/clients/ICTC/08-088/pdfs/ICTC_HRGuide_Intro.pdf#nameddest=introduction

Weirdly, this works in IE only
http://myaccuratedev.com/clients/ICTC/08-088/pdfs/ICTC_HRGuide_Intro.pdf#introduction
0
AccurateDesignAuthor Commented:
Turns out apparently the only browser it doesn't work is in Chrome, unless I add "nameddest" in the URL but then it doesn't work in IE and Firefox.

Is there a way to detect Chrome and add "nameddest" in the URL?
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I would just use the page.  What I see here, http://tools.ietf.org/html/rfc3778#page-3 is there is a difference between a bookmark and nameddest.  Maybe you need to add a nameeddest in the pdf as well as the bookmark.   Are you generating the pdf's dynamically?

The page seems the easy route.
0
AccurateDesignAuthor Commented:
I would like to, but the client is expecting to work the same way since I am doing an update with a newer PDF.

So I found a code below, not sure if it's the right syntax (really new in ASP)... but it is not working

<%
If (Sys.Browser.agent == Sys.Browser.Chrome) Then
	Response.Write("is chrome")
End If
%>

Open in new window

0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
That is not classic asp.

Put this towards the top of your page
<%
dim agent, isChrome
isChrome=0
agent=lcase(Request.ServerVariables("HTTP_USER_AGENT"))
if instr(agent,"chrome") then 
	isChrome=1
end if
%>

Open in new window

Now in your code where you need to test for chrome
<%
if isChrome=1 then
	response.write "We have chrome"
	else
	response.write "No Chrome here"
end if
%>

Open in new window

What the top portion does is look for the word chrome.  If you simply do a response.write agent in the code above you will see something like below.

mozilla/5.0 (macintosh; intel mac os x 10_8_5) applewebkit/537.36 (khtml, like gecko) chrome/29.0.1547.76 safari/537.36

the instr command above looks for the the first occurrence of "chrome"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AccurateDesignAuthor Commented:
works perfectly!

here is the final code I ended up using:

<%
'Detecting the Chrome browser to add later on some specific code'
dim agent, isChrome
isChrome=0
agent=lcase(Request.ServerVariables("HTTP_USER_AGENT"))
if instr(agent,"chrome") then 
	isChrome=1
end if

'If the current browser is Chrome add some special code'
if isChrome=1 then
	goToBookmark = "#nameddest="
	else
	goToBookmark = "#"	
end if
%>

Open in new window


and later in the page I called this variable and now the bookmark linking feature works fine in IE, Firefox and Chrome... yay! :)
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
This was a good question. I learned something new in researching this.  Bookmark vs Named Destination.   Thanks for the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.