|Executing programs with options [message #479507]
||Tue, 11 August 2009 11:00
Originally posted by: pankaj.shinde.sas.com|
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
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.
Powered by FUDForum
. Page generated in 0.01682 seconds