GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 24-Oct-2005, 01:54
bryan523 bryan523 is offline
Junior Member
 
Join Date: Aug 2005
Posts: 32
bryan523 is on a distinguished road

view PDF files using java


Hi all,

does someone know how to view PDF file using java? i would like to view the pdf files while i run the java program! hope someone can show me the coding example! Thanks!
  #2  
Old 24-Oct-2005, 08:24
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 929
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Re: view PDF files using java


Hi bryan,

Do you want to open the files in Adobe reader or your java application?

If you want to read the file in a java application itself, it is difficult.

Else,
You can use the Runtime.exec function.
Like this:
JAVA Code:
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + file);

So, by specifying a *.pdf file, Windows will try to start the appropriate program (Adobe Reader or whatever application is registered for PDF files).

You can find more information about Runtime.exec, visit this link:
Runtime java reference

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

How to use Runtime.exec()

If you want it to open in your java application itself, visit this link:
Java Libraries to read and write pdf files

Regards,
Paramesh.
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #3  
Old 25-Oct-2005, 03:57
bryan523 bryan523 is offline
Junior Member
 
Join Date: Aug 2005
Posts: 32
bryan523 is on a distinguished road

Re: view PDF files using java


Hi paramesh,

thanks to help me but i m to weak in java so i cant get to solve the problem with the function u gv me! can u gv me a simple full program example here that hw to call the pdf file out using java program which when i run the java program then the pdf file will open using acrobat reader. my pdf file name is chart.pdf and the directory is ( C:\chart.pdf ). soli cos disturb u n gv u trouble.

Rgds,
bryan
  #4  
Old 25-Oct-2005, 04:29
Paramesh's Avatar
Paramesh Paramesh is offline
Regular Member
 
Join Date: Sep 2005
Location: The Milky Way
Posts: 929
Paramesh is a jewel in the roughParamesh is a jewel in the roughParamesh is a jewel in the rough

Re: view PDF files using java


Hi Bryan,

Here is a sample program:
JAVA Code:
class pdfopen           //class pdfopen
{
    public static void main(String args[])       //main function
    {
        try                                      //try statement
        {
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "c:\\chart.pdf");   //open the file chart.pdf

        } catch (Exception e)                    //catch any exceptions here
          {
              System.out.println("Error" + e );  //print the error
          }
    }
}

I hope you know what try and catch statements are!
If you have read those links, then you'll understand why this is a bad method. But it is simple. Thats why i posted it.

Quote:
soli cos disturb u n gv u trouble.
Feel free to ask your doubts.

Cheers,
Paramesh.
__________________

Don't walk in front of me, I may not follow.
Don't walk behind me, I may not lead.
Just walk beside me and be my friend.
  #5  
Old 25-Oct-2005, 04:54
bryan523 bryan523 is offline
Junior Member
 
Join Date: Aug 2005
Posts: 32
bryan523 is on a distinguished road

Re: view PDF files using java


Thanks you very much paramesh! i manage to open it already! Thanks to help a java newbie!

Rgds,
bryan
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
update view from a for loop Rabbit_May MS Visual C++ / MFC Forum 0 25-Mar-2005 10:43
Checking source codes of image, audio and video files onauc C Programming Language 5 26-Feb-2005 22:47
Browser's Language Interpreters onauc Open Discussion Forum 0 18-Nov-2004 19:53
Apache2 config issues monev Apache Web Server Forum 2 28-Jun-2004 07:19

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 15:11.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.