Executing programs with options [message #479507] |
Tue, 11 August 2009 11:00 |
Eclipse User |
|
|
|
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 |
|
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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03562 seconds