Page 1 of 1

How to open .odt file in Twebbrowser - Delphi

Posted: Tue Jul 24, 2018 11:15 am
by dramiljas
Hello,
i wont open .odt file in Twebbrowser component
I want to open the .odt file in tWebBrowser components. I'm programming in delphi.
Word document .doc file open with tWebBrowser.navigate(path). How to open openoffice text document .odt in twebBrowser component ?
If in path .doc file works fine. If in path .odt file a window appears on the screen asking if I want to open, save or quit. When I say that I open the .odt file it is opened outside the twebBrowser component.
How to open openoffice text document .odt in twebBrowser component ?
Help please,

Moved to more appropriate forum section, floris v, moderator

Re: How to open .odt file in Twebbrowser - Delphi

Posted: Tue Jul 24, 2018 2:32 pm
by floris v
See http://docwiki.embarcadero.com/Librarie ... WebBrowser - the component uses Microsoft's Shell Doc Object and Control Library (SHDOCVW.DLL). Therefore it can handle doc files if MS decided that IE should be able to display doc files. You will have to add that kind of functionality for displaying odt files - link to the UNO bridge or something like that. Hard work ahead, most likely.

Re: How to open .odt file in Twebbrowser - Delphi

Posted: Wed Jul 25, 2018 11:56 am
by dramiljas
Thank you. Can you suggest me a component for Delphi programming language which can display an .ODT document as does TwebBrowser?

Re: How to open .odt file in Twebbrowser - Delphi

Posted: Wed Jul 25, 2018 12:24 pm
by floris v
I'm afraid not. You will have to google for that, probably, or ask it on the Delphi and Lazarus forums. You may have to adapt Lazarus code to fit Delphi, there are some differences. I haven't done any serious programming for a while now, so can't really help you further along.

Re: How to open .odt file in Twebbrowser - Delphi

Posted: Wed Jul 25, 2018 3:30 pm
by Lupp
Disclaimer: This is a topic far off my specific interest and knowledge.

@dramiljas

-1- Independent of whether you use Delphi or whatever: Why do you expect there is a way to open text documents created with AOO or LibreOffice (.odt) in webbrowsers? Do you know one? (Without trusting a remote service for intermediary conversions?)

-2- What do you expect of your opened .odt? Shall the browser just act as a reader or shall there be editing?

-3- I found this old post: https://www.maketecheasier.com/read-odt ... e-browser/ Do you know more recent posts on the topic?

-4- Did you read https://superuser.com/questions/1182330 ... er/1182340 ?

-5- If there is access to the original AOO or LibreOffice software: Did you consider to use it for a "conversion on the fly" from .odt to .html?

Re: How to open .odt file in Twebbrowser - Delphi

Posted: Thu Jul 26, 2018 12:31 pm
by dramiljas
Thenk you all.
I just want to read the .odt file. Not to change it. I searched the internet and I did not find a solution. That's why I asked the question to this forum. I was hoping someone had an idea.
Thanks again.

Re: How to open .odt file in Twebbrowser - Delphi

Posted: Thu Jul 26, 2018 1:36 pm
by Lupp
I wouldn't trust MS, of course, but if you do (??):
There is an online service described here:
https://support.office.com/en-us/articl ... 61A104544E

That's to the effect that you can use the query-URL below to get "office documents" visualised in your browser.

Code: Select all

https://view.officeapps.live.com/op/view.aspx?src=
Of course, you need in addition to append the original URL from where your document is accessible. Regarding the needs of URL syntax some special characters must be given in the "%-escaped" notation there. The "%3A%2F%2F" e.g. means "://" in the URL of my example file:

Code: Select all

http%3A%2F%2Fpsilosoph.de%2FFreeOfficeForums%2FMSonlineServiceTest.odt
Glued together this gives the URL (with query part):

Code: Select all

https://view.officeapps.live.com/op/view.aspx?src=http%3A%2F%2Fpsilosoph.de%2FFreeOfficeForums%2FMSonlineServiceTest.odt
You may test it by copying it into the URL line of your browser. (Without a line break, of course.)

Edit1:
As I meanwhile tested with Firefox you don't need the mentioned encoding there, at least in simple cases. For the example above also

Code: Select all

https://view.officeapps.live.com/op/view.aspx?src=http://psilosoph.de/FreeOfficeForums/MSonlineServiceTest.odt
works.