Which is the best way of opening a PDF and HTML local files from Pharo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Which is the best way of opening a PDF and HTML local files from Pharo

Offray Vladimir Luna Cárdenas-2
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


Reply | Threaded
Open this post in threaded view
|

Re: Which is the best way of opening a PDF and HTML local files from Pharo

HilaireFernandes
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


Reply | Threaded
Open this post in threaded view
|

Re: Which is the best way of opening a PDF and HTML local files from Pharo

HilaireFernandes
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


Reply | Threaded
Open this post in threaded view
|

Re: Which is the best way of opening a PDF and HTML local files from Pharo

Offray Vladimir Luna Cárdenas-2
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.


Reply | Threaded
Open this post in threaded view
|

Re: Which is the best way of opening a PDF and HTML local files from Pharo

alistairgrant
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
<[hidden email]> 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.
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Which is the best way of opening a PDF and HTML local files from Pharo

Offray Vladimir Luna Cárdenas-2
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
> <[hidden email]> 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.
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Which is the best way of opening a PDF and HTML local files from Pharo

David T. Lewis
In reply to this post by Offray Vladimir Luna Cárdenas-2
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


Reply | Threaded
Open this post in threaded view
|

Re: Which is the best way of opening a PDF and HTML local files from Pharo

Holger Freyther

> On 26 Feb 2017, at 12:27, David T. Lewis <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Which is the best way of opening a PDF and HTML local files from Pharo

alistairgrant
In reply to this post by Offray Vladimir Luna Cárdenas-2
Hi Offray,

On 26 February 2017 at 11:36, Offray Vladimir Luna Cárdenas
<[hidden email]> 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