|
Re: Program.findProgram() returns null [message #446264 is a reply to message #446262] |
Tue, 23 November 2004 03:12   |
Eclipse User |
|
|
|
Originally posted by: wkrain.hotmail.com
"Christian Hauser" <c.hauser@active.ch> wrote in message
news:cntujm$j3q$1@www.eclipse.org...
> Hello everybody
>
> I need to open PDF files from an SWT application, but I also would like
> to inform the user that he/she needs a program such as Adobe Reader to
> open PDF files if no such program is registered for the extension "pdf".
>
> However, the method Program.findProgram("pdf") often returns null even
> if there is a program associated with PDF files. The problem mainly
> occurs on Windows 2000 and Linux.
>
> Dani had the same problem with HTML files as mentioned in bug 71228:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=71228
>
> Could anyone please give me a hint on how to solve this problem? Might
> this get fixed anytime soon? Are there any alternatives on how to open a
> PDF file from within an SWT application? I'd rather not use
> java.lang.Runtime#exec.
>
> Thanks in advance for any help on how I could solve this problem.
>
> Christian
|
|
|
Re: Program.findProgram() returns null [message #446265 is a reply to message #446262] |
Tue, 23 November 2004 03:18   |
Eclipse User |
|
|
|
Originally posted by: wkrain.hotmail.com
Hi buddy
I can give mw a hint on how to slov this problem,There are an
alternatives on how to open a PDF file from within
an swt application. I need point this mentod is great way to slove your
problem.
You can integrate Activex into SWT application. For example
public class PDFViewer extends ApplicationWindow
{
private OleControlSite site;
private OleAutomation auto;
public PDFViewer()
{
super(null);
this.addMenuBar();
}
protected Control createContents(Composite parent)
{
Shell shell = this.getShell();
shell.setText("PDF Viewer");
shell.setSize(500, 450);
OleFrame frame = new OleFrame(shell, SWT.NONE);
try
{
site = new OleControlSite(frame, SWT.NONE, "PDF.PdfCtrl.5");
auto = new OleAutomation(site);
..........................
public void showPdfControl()
{
site.doVerb(OLE.OLEIVERB_SHOW);
}
public void loadFile(String file)
{
showPdfControl();
int[] rgdispid = auto.getIDsOfNames(newString[]{"LoadFile"});
int dispIdMember = rgdispid[0];
Variant[] rgvarg = new Variant[1];
rgvarg[0] = new Variant(file);
Variant pVarResult =auto.invoke(dispIdMember,rgvarg);
}
I hope so this article will help you slove your problem!
"Christian Hauser" <c.hauser@active.ch> wrote in message
news:cntujm$j3q$1@www.eclipse.org...
> Hello everybody
>
> I need to open PDF files from an SWT application, but I also would like
> to inform the user that he/she needs a program such as Adobe Reader to
> open PDF files if no such program is registered for the extension "pdf".
>
> However, the method Program.findProgram("pdf") often returns null even
> if there is a program associated with PDF files. The problem mainly
> occurs on Windows 2000 and Linux.
>
> Dani had the same problem with HTML files as mentioned in bug 71228:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=71228
>
> Could anyone please give me a hint on how to solve this problem? Might
> this get fixed anytime soon? Are there any alternatives on how to open a
> PDF file from within an SWT application? I'd rather not use
> java.lang.Runtime#exec.
>
> Thanks in advance for any help on how I could solve this problem.
>
> Christian
|
|
|
Re: Program.findProgram() returns null [message #446290 is a reply to message #446265] |
Tue, 23 November 2004 07:55   |
Christian Hauser Messages: 189 Registered: July 2009 |
Senior Member |
|
|
Thanks a lot for your code. I'll try that. However, as this seems to be
a Windows-only solution I'm not sure whether I'll go for it.
Christian
wkrain wrote:
> Hi buddy
>
> I can give mw a hint on how to slov this problem,There are an
> alternatives on how to open a PDF file from within
> an swt application. I need point this mentod is great way to slove your
> problem.
>
> You can integrate Activex into SWT application. For example
>
> public class PDFViewer extends ApplicationWindow
> {
> private OleControlSite site;
> private OleAutomation auto;
> public PDFViewer()
> {
> super(null);
> this.addMenuBar();
> }
>
> protected Control createContents(Composite parent)
> {
> Shell shell = this.getShell();
> shell.setText("PDF Viewer");
> shell.setSize(500, 450);
> OleFrame frame = new OleFrame(shell, SWT.NONE);
> try
> {
> site = new OleControlSite(frame, SWT.NONE, "PDF.PdfCtrl.5");
> auto = new OleAutomation(site);
> .........................
>
>
>
> public void showPdfControl()
> {
> site.doVerb(OLE.OLEIVERB_SHOW);
> }
>
> public void loadFile(String file)
> {
> showPdfControl();
> int[] rgdispid = auto.getIDsOfNames(newString[]{"LoadFile"});
> int dispIdMember = rgdispid[0];
>
> Variant[] rgvarg = new Variant[1];
> rgvarg[0] = new Variant(file);
> Variant pVarResult =auto.invoke(dispIdMember,rgvarg);
> }
>
> I hope so this article will help you slove your problem!
>
>
> "Christian Hauser" <c.hauser@active.ch> wrote in message
> news:cntujm$j3q$1@www.eclipse.org...
>
>>Hello everybody
>>
>>I need to open PDF files from an SWT application, but I also would like
>>to inform the user that he/she needs a program such as Adobe Reader to
>>open PDF files if no such program is registered for the extension "pdf".
>>
>>However, the method Program.findProgram("pdf") often returns null even
>>if there is a program associated with PDF files. The problem mainly
>>occurs on Windows 2000 and Linux.
>>
>>Dani had the same problem with HTML files as mentioned in bug 71228:
>>https://bugs.eclipse.org/bugs/show_bug.cgi?id=71228
>>
>>Could anyone please give me a hint on how to solve this problem? Might
>>this get fixed anytime soon? Are there any alternatives on how to open a
>>PDF file from within an SWT application? I'd rather not use
>>java.lang.Runtime#exec.
>>
>>Thanks in advance for any help on how I could solve this problem.
>>
>>Christian
>
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.02399 seconds