Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Executing programs with options
Executing programs with options [message #479507] Tue, 11 August 2009 11:00 Go to next message
Eclipse UserFriend
Originally posted by: pankaj.shinde.sas.com

Hi,
I was trying to print a pdf file from my eclipse plugin. In eclipse3.3 or
below version I was using following code to print pdf files.

String pdfFileAbsolutePath = "c:/MyFile.pdf";
Program pdfViewer = Program.findProgram(".pdf");
pdfViewer.execute("/p " + pdfFileAbsolutePath);

It was working fine. But it stopped working in Eclipse 3.4 or higher
versions.
In Eclipse 3.4 onwards, in the execute() method of Program class, the
eclipse is surrounding the file path with double-quotes("). So the actual
command getting executed is

"C:\Program Files\Adobe\Reader 9.0\Reader\Acrord32.exe" "/p c:/MyFile.pdf"

Due to double-quotes, the command has changed and now it is not able to
recognize the print command. I tried playing with double-quotes but none
are working for me.

"Program" class does not expose an API to get the executable path. If
somehow I am able to get the PDF reader path I can make use of
Runtime.getRuntime().exec(PrintCommand) for printing.

Please let me know is there any better way to print the PDF file.

Thanks,
Pankaj
Re: Executing programs with options [message #479571 is a reply to message #479507] Tue, 11 August 2009 15:01 Go to previous messageGo to next message
Dilton McGowan II is currently offline Dilton McGowan IIFriend
Messages: 110
Registered: July 2009
Senior Member
On Tue, 11 Aug 2009 11:00:56 +0000, Pankaj Shinde wrote:

> Hi,
> I was trying to print a pdf file from my eclipse plugin. In eclipse3.3
> or below version I was using following code to print pdf files.
>
> String pdfFileAbsolutePath = "c:/MyFile.pdf"; Program pdfViewer =
> Program.findProgram(".pdf"); pdfViewer.execute("/p " +
> pdfFileAbsolutePath);
>
> "Program" class does not expose an API to get the executable path. If
> somehow I am able to get the PDF reader path I can make use of
> Runtime.getRuntime().exec(PrintCommand) for printing.
>
> Please let me know is there any better way to print the PDF file.
>

Consider making an SWT Browser instance and tell it to open the PDF. It
works on Ubuntu and Windows for me.
Re: Executing programs with options [message #480730 is a reply to message #479571] Tue, 18 August 2009 11:05 Go to previous message
Eclipse UserFriend
Originally posted by: pankaj.shinde.sas.com

Dilton,
I am able to open the PDF using 'Program' class. But what I want is,
specifying some options while opening the PDF file (e.g. I want specify
option '/p' while opening the PDF file - so that pdf file opens up for
printing only).

-Pankaj
Previous Topic:Transparent Image as layer
Next Topic:Library to extract frames from AVI files
Goto Forum:
  


Current Time: Tue Mar 19 06:41:09 GMT 2024

Powered by FUDForum. Page generated in 0.02375 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top