AccurateDesign
asked on
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
This was made back in 2008, so is it possible that the code has changed since then?
Here is the link
What is not working? Seems to work fine in chrome
ASKER
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
Also the red subtitles on the left don't seem to be working as well
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
change to
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 ?
#nameddest=Introduction or #page=3
Where you have
<embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#" />
change to
<embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#nameddest=Introduction" />
or <embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#page=3" />
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%>" />
Edit to last code:
However, to be super safe:
<embed id="PDF_Area" name="PDF_Area" class="pdf_width" src="pdfs/ICTC_HRGuide_Intro.pdf#nameddest=<%=request.querystring("bookmark")%>" />
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%>" />
ASKER
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/c lients/ICT C/08-088/p dfs/ICTC_H RGuide_Int ro.pdf#pag e=3
Not working in Firefox
http://myaccuratedev.com/c lients/ICT C/08-088/p dfs/ICTC_H RGuide_Int ro.pdf#nam eddest=int roduction
Weirdly, this works in IE only
http://myaccuratedev.com/c lients/ICT C/08-088/p dfs/ICTC_H RGuide_Int ro.pdf#int roduction
Works in Firefox
http://myaccuratedev.com/c
Not working in Firefox
http://myaccuratedev.com/c
Weirdly, this works in IE only
http://myaccuratedev.com/c
ASKER
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?
Is there a way to detect Chrome and add "nameddest" in the URL?
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.
The page seems the easy route.
ASKER
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
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
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
works perfectly!
here is the final code I ended up using:
and later in the page I called this variable and now the bookmark linking feature works fine in IE, Firefox and Chrome... yay! :)
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
%>
and later in the page I called this variable and now the bookmark linking feature works fine in IE, Firefox and Chrome... yay! :)
This was a good question. I learned something new in researching this. Bookmark vs Named Destination. Thanks for the points.