aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Saving as pdf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Saving as pdf" Watch "Saving as pdf" New topic
Author

Saving as pdf

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Hi,
Using this we are not able to connect to another system which provides service. This is working properly when both client system and server on the LAN.
Thank You in advance.
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I have an extraction.jsp which generates an image file.This page has a 'download' button and 'close' buttons.when I click download it has to save it as pdf file(for which a function is written-shown below) when the system is on internet/intranet/LAN etc

The function is ...



-------
pdfurl is not being assigned to window.extPane.location.href and therefore it unable to call savepdf function...


Needed urgent inputs...thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

Moved to the HTML/JavaScript forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Thanks for the correction but i need inputs big time...

The problem is that it is working when it is in offline mode (locally,no internet)
but when online, "window.extPane.location.href =pdfURL " is not working...
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Sounds like permissions issues. Why don't you just have the server generate a pdrf file and send it down to the client and not rely on unreliable browser features.

Eric
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Thanks Eric! I was desperate for someone to respond.
Why don't you just have the server generate a pdrf file
My problem is how do I do that?
Is there nothing wrong with "window.extPane.location.href =url " ?? or should i use "window.location.href" or something else...
I would take you suggestion (quickest possible one) A liitle briefing would be of great help...Thanks!
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Sounds like permissions issues

Little more briefing...
I have two jsp's extract.jsp and download.jsp
In extract.jsp which has java code to call the webservice which will reutrn a ".png" image file (no permission problems even on internet) .Next step is to download this as pdf.
but in download.jsp I have written JS code but when download button is clicked , the internet connection goes off from that point...

I hope I am able to explain my issue !!!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
If extract.jsp can return a png, set it up so it can return a pdf.

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
That's somehow not happening and the point I am trying to make.
While returning .pdf the internet connection goes off ... I think somehow the request doesn't go to the webserver and hence it doesn't return .pdf
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
not able to understand the issue? I would like to know how to save as pdf...i should atleast save my image file as pdf when i click download link. Any code snippets or inputs for this??
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18155
    
    8

I have to agree with Eric... If you can write code which downloads a PNG, then the same code with very minor changes can download a PDF. You don't need any special Javascript, either, just an ordinary link to the server URL which generates the PDF.
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Ok...this is the java class ..




I am just not finding that minor change here... can someone go through this a help me make a move? thanks!
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Ok,I tried the above way but it disturbed my whole application.So i revert back to the old code.




This works fine on LAN and intranet
but for a independent user on the internet this is causing problems.
So this same line which is showing pdf when system is on LAN and intranet is failing with system connected to internet.Where is the flaw??Urgent... thanks!

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
You're relying on the user's browser to be able to show PDFs. That's simply not a valid assumption to make. The browser may be set to save PDFs automatically, or display them internally with the help of a plugin, or start an external process. That's something the web app has no control over.


Ping & DNS - updated with new look and Ping home screen widget
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
I think that's the best practise,I wish I had time to do that but right now I think I have to stick to this...

small snippet to bring more clarity...



output...
-------------


The imgFile is /maps/4772.pdf
the udpath is : D:\workspace_final\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\GoaGis\maps\4772.pdf
in forPrint option


---------------

I have to get this file location (in web server) and put it in client/end user system...
How do I take it from this and display it on end user system who is on his own internet? When he uses his internet and accesses the site he is requesting the web server on the LAN but the pdf which is available on the LAN is not being passed on to the enduser...

Issue with tomcat?
//// instead of // for url?
breaking my head with this...
I hope I made it clear
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
Add on :

In the struts.xml side I am directing it to a page...It is not going to that page even after success....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving as pdf
 
Similar Threads
Username And password
Change the JVM default ClassLoader
Copy file
System Design & System Architecture
How to find the system requirement