Which is the best way of opening a PDF and HTML local files from Pharo
Hi, I'm trying to open some local files from Pharo. They're in PDF and HTML format. I thought that I could use WebBrowser, so it can delegate to the browser opening the files, without any other requirement, but is not working. There is a better way to open such files from several platforms? Cheers, Offray
Hi Offray, You may want to do it with a hierarchy of classes, one for each host, to handle concretely the PDF and HTML OS viewer you want to use, and another class to handle it uniformly. For example MyOperation>>openPdf: aFile then it will delegate to LinuxOperation/WindowsOperation/MacOperation depending on the host running the VM. That way you could add up more operation when needed. But likely there is already something like that in the system but I can't see. Hilaire Le 24/02/2017 à 02:11, Offray Vladimir Luna Cárdenas a écrit :
I'm trying to open some local files from Pharo. They're in PDF and HTML format. I thought that I could use WebBrowser, so it can delegate to the browser opening the files, without any other requirement, but is not working. There is a better way to open such files from several platforms?
-- Dr. Geo http://drgeo.eu
Oh, you can add your extension to the OSPlateform hierarchy. So one your extensions added in the hierarchy, your code will use it with an uniform: OSPlateforme current openPdf: 'grafoscopio.pdf' Le 24/02/2017 à 18:55, Hilaire a écrit :
But likely there is already something like that in the system but I can't see.
-- Dr. Geo http://drgeo.eu
Thanks Hilaire. I was thinking in something that depend on OSProcess and invoke xdg-open on Linux, for example, but is not working neither. OSProcess command: 'xdg-open ', pdfPathString doesn't open the PDF file :-/. Cheers, Offray On 24/02/17 13:02, Hilaire wrote:
Oh, you can add your extension to the OSPlateform hierarchy.
So one your extensions added in the hierarchy, your code will use it with an uniform:
OSPlateforme current openPdf: 'grafoscopio.pdf'
Le 24/02/2017 à 18:55, Hilaire a écrit :
But likely there is already something like that in the system but I can't see.
Hi Offray, Which version of Pharo are you running? My understanding is that Pharo5 & 6 use OSSubprocess, not OSProcess. I'm using xdg-open to open pdf files on linux (Arch): | proc | proc := OSSUnixSubprocess new. proc command: 'xdg-open'; arguments: (Array with: url). proc run. UIManager inform: 'Opened: ', url. url is the path to the file in this case. You can check the exit status with: proc exitStatusInterpreter e.g.: proc exitStatusInterpreter isSuccess Cheers, Alistair On 25 February 2017 at 05:07, Offray Vladimir Luna Cárdenas <offray.luna@mutabit.com> wrote:
Thanks Hilaire.
I was thinking in something that depend on OSProcess and invoke xdg-open on Linux, for example, but is not working neither.
OSProcess command: 'xdg-open ', pdfPathString
doesn't open the PDF file :-/.
Cheers,
Offray
On 24/02/17 13:02, Hilaire wrote:
Oh, you can add your extension to the OSPlateform hierarchy.
So one your extensions added in the hierarchy, your code will use it with an uniform:
OSPlateforme current openPdf: 'grafoscopio.pdf'
Le 24/02/2017 à 18:55, Hilaire a écrit :
But likely there is already something like that in the system but I can't see.
Hi Alistair, Unix process is making the task properly. Now I wonder how I can load the proper OS-Windows, OS-Unix or OS-Mac in Monticello, so the Grafoscopio package loads only the requirements for making this work accordingly to the platform where is running. Cheers, Offray On 24/02/17 16:54, Alistair Grant wrote:
Hi Offray,
Which version of Pharo are you running? My understanding is that Pharo5 & 6 use OSSubprocess, not OSProcess.
I'm using xdg-open to open pdf files on linux (Arch):
| proc |
proc := OSSUnixSubprocess new. proc command: 'xdg-open'; arguments: (Array with: url). proc run. UIManager inform: 'Opened: ', url.
url is the path to the file in this case.
You can check the exit status with:
proc exitStatusInterpreter
e.g.:
proc exitStatusInterpreter isSuccess
Cheers, Alistair
On 25 February 2017 at 05:07, Offray Vladimir Luna Cárdenas <offray.luna@mutabit.com> wrote:
Thanks Hilaire.
I was thinking in something that depend on OSProcess and invoke xdg-open on Linux, for example, but is not working neither.
OSProcess command: 'xdg-open ', pdfPathString
doesn't open the PDF file :-/.
Cheers,
Offray
On 24/02/17 13:02, Hilaire wrote:
Oh, you can add your extension to the OSPlateform hierarchy.
So one your extensions added in the hierarchy, your code will use it with an uniform:
OSPlateforme current openPdf: 'grafoscopio.pdf'
Le 24/02/2017 à 18:55, Hilaire a écrit :
But likely there is already something like that in the system but I can't see.
Hi Offray, On 26 February 2017 at 11:36, Offray Vladimir Luna Cárdenas <offray.luna@mutabit.com> wrote:
Unix process is making the task properly.
Great to hear!
Now I wonder how I can load the proper OS-Windows, OS-Unix or OS-Mac in Monticello, so the Grafoscopio package loads only the requirements for making this work accordingly to the platform where is running.
Unfortunately this is beyond my experience with configuration management. However I would have thought there is a good argument that all platforms should be loaded so that the image remains platform independent. Cheers, Alistair
On Fri, Feb 24, 2017 at 01:07:18PM -0500, Offray Vladimir Luna C??rdenas wrote:
Thanks Hilaire.
I was thinking in something that depend on OSProcess and invoke xdg-open on Linux, for example, but is not working neither.
OSProcess command: 'xdg-open ', pdfPathString
doesn't open the PDF file :-/.
Hi Offray, I tried "OSProcess command: 'xdg-open ', pdfPathString" in Pharo, and it works for me. Maybe check to be sure that pdfPathString is right? Dave
On 26 Feb 2017, at 12:27, David T. Lewis <lewis@mail.msen.com> wrote:
Hi,
I tried "OSProcess command: 'xdg-open ', pdfPathString" in Pharo, and it works for me. Maybe check to be sure that pdfPathString is right?
if you don't control pdfPathStrig you will also need to escape this string. I don't know if Pharo/OSProcess has support for the necessary escaping. E.g. 'foo.pdf; rm -rf /' as input should not lead to the removal of your system. :) holger
participants (5)
-
Alistair Grant -
David T. Lewis -
Hilaire -
Holger Freyther -
Offray Vladimir Luna Cárdenas