How to open an PDF file from Java Application

HiI am developing a GUI application in java swing.on clicking one button, I want to open PDF file from my swing application.Is there any API through which I can achieve this?Tapan MaruSun Certified Java Programmer
[255 byte] By [tapan_javaprogrammera] at [2007-11-27 0:39:59]
# 1
Hi Tapan;see Post : http://forum.java.sun.com/thread.jspa?threadID=617767it will give solution for your problem in Windows.
Chowdarya at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 2
http://www.lowagie.com/iText/download.htmlregardsAniruddha
Aniruddha-Herea at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 3
Dear Mr. Group LeaderThanks for the link but thats not my solution.I am already using iText API for creating pdf files.I think u have not read the problem (as i have not read the JTable code)please "dont mind"Tapan Maru
tapan_javaprogrammera at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 4
With java 6 I think you can open the default viewer using the java.awt.Desktop class.-Puce
Pucea at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 5

Here's a way to do it (if I understand you correctly). Just let explorer.exe do it for you.

import java.awt.*;

public class openPDF

{

Desktop desktop = Desktop.getDesktop();

public openPDF()

{

open("test.pdf");

}

public void open(String path)

{

try

{

Runtime.getRuntime().exec("explorer.exe "+path);

} catch(Exception e) { System.out.println("NAI! ERROR!\n"+e); }

}

public static void main(String[] args)

{

openPDF myApplication = new openPDF();

}

}

alienchilda at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 6

you may find something here

http://schmidt.devlib.org/java/libraries-pdf.html

or check this old thread

http://forum.java.sun.com/thread.jspa?threadID=288610&messageID=1785204

or this link

http://www.google.com/search?hl=en&q=display+pdf+with+swing&btnG=Search

suparenoa at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 7

> Here's a way to do it (if I understand you

> correctly). Just let explorer.exe do it for you.

>

> > import java.awt.*;

>

> public class openPDF

> {

> Desktop desktop = Desktop.getDesktop();

>

> public openPDF()

> {

> open("test.pdf");

> }

>

> public void open(String path)

> {

> try

> {

> Runtime.getRuntime().exec("explorer.exe "+path);

> } catch(Exception e) { System.out.println("NAI!

> I! ERROR!\n"+e); }

> }

>

> public static void main(String[] args)

> {

> openPDF myApplication = new openPDF();

> }

>

> }

>

Why do you have a Desktop object as a member but instead of using it, you execute a command with Runtime (which is not platform independent!)?

-Puce

Pucea at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 8
http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#open(java.io.File)
Pucea at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 9
hi!i hope this will be able to help you. http://www.adobe.com/products/acrviewer/acrvdnld.htmlregardsAniruddha
Aniruddha-Herea at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 10
Cause I copy/pasted a small class file I already had and forgot to edit out the Desktop object.
alienchilda at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...
# 11
> Cause I copy/pasted a small class file I already had> and forgot to edit out the Desktop object.? I'd suggest to actually use the Desktop object if you're using java 6 and NOT system calls, where possible.-Puce
Pucea at 2007-7-11 22:52:32 > top of Java-index,Desktop,Core GUI APIs...