How to open .odt file in Twebbrowser - Delphi

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
dramiljas
Posts: 3
Joined: Tue Jul 24, 2018 10:59 am

How to open .odt file in Twebbrowser - Delphi

Post 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
Windows 10, Open office 4.1.5
User avatar
floris v
Volunteer
Posts: 4430
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

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

Post 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.
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
dramiljas
Posts: 3
Joined: Tue Jul 24, 2018 10:59 am

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

Post by dramiljas »

Thank you. Can you suggest me a component for Delphi programming language which can display an .ODT document as does TwebBrowser?
Windows 10, Open office 4.1.5
User avatar
floris v
Volunteer
Posts: 4430
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

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

Post 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.
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
User avatar
Lupp
Volunteer
Posts: 3548
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

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

Post 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?
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
dramiljas
Posts: 3
Joined: Tue Jul 24, 2018 10:59 am

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

Post 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.
Windows 10, Open office 4.1.5
User avatar
Lupp
Volunteer
Posts: 3548
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

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

Post 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.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply