File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with anchor tag # when trying to open pdf

 
vamshidhar nimbagiri
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a requirement to open a PDF document (to open an existing pdf on server not creating) with showing the appropriate section which user clicked and also need to update the count in database.

In order to do this i have followed these steps:
Ex: Lets say XYZ.pdf file which has a, b and c sections. To show section a in the URL it is some thing like ../../XYZ.pdf#a


1. First, i called my controller class when user clicks the link (to update the count in database) and in controller i used Spring MVC redirect function to open XYZ.pdf#a. But the problem is its removing the # from URL and showing entire XYZ.pdf opening first page instead of showing #a section. That too this is happening in IE browser not in Firefox.
2. I have tried another way by calling a dummy jsp from controller and onload of that jsp i did location.href function to show the pdf document. It worked but the problem is with back button, if i use POST method back button displays page cannot be displayed message, if use GET method back is not working i will be in same page forever it wont allow you to go back.

I hope i cleared explained my problem, Could any one please help me.

Thanks in advance!

- Vamshidhar Nimbagiri

 
vamshidhar nimbagiri
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

After trying many alternative solutions. At last i found one which is working.

In my controller i setting the location to response header like this:

response.setStatus(Response.SC_MOVED_TEMPORARILY);
response.setHeader("Location", docLoc); // where docLoc is the absolute path of the location of the document.


 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic