DocumentViewer and the gb.pdf components are OK for .pdf files.
What is the best way to view the other document types (.doc, .ODT, .txt)?
Is there a way, for example to display a .doc file in imageview?
Viewing document files
-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
- Quincunxian
- Posts: 173
- Joined: Sunday 25th June 2017 12:14am
- Location: Western Australia
Re: Viewing document files
Hi Bill,
Do you need to open the document "in program" or just open the document externally for review ?
If just for a review, you can use the Linux application xdg-open {document path}
xdg-open will open most document types within their native applications and is installed on most common Linux distros. You can install easily it if it's not on yours.
From within Gambas you would use something like this:
just using www.someaddress.com won't work.
For example, using xdg-open with the path:
"https://www.google.com/search?q=" & "{search term}+{search term}+...
will open Google in your browser with the results of the search terms that you entered.
Do you need to open the document "in program" or just open the document externally for review ?
If just for a review, you can use the Linux application xdg-open {document path}
xdg-open will open most document types within their native applications and is installed on most common Linux distros. You can install easily it if it's not on yours.
From within Gambas you would use something like this:
Exec ["xdg-open", SelectedPath]
It will also open a web link in your default browser but the path must have the http header included.just using www.someaddress.com won't work.
For example, using xdg-open with the path:
"https://www.google.com/search?q=" & "{search term}+{search term}+...
will open Google in your browser with the results of the search terms that you entered.
Cheers - Quin.
I code therefore I am
I code therefore I am
- cogier
- Site Admin
- Posts: 1125
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: Viewing document files
'xdg' is being deprecated https://github.com/github/hub/issues/1473
If you add the 'gb.desktop' component you can use
If you want to display something like an .odt or .doc then I don't thing Gambas can help you read the files but LibreOffice can convert those files to a text file, below converts the spreadsheet file 'temp.ods' to a 'csv' file: -
If you add the 'gb.desktop' component you can use
Desktop.Open(User.home &/ "MyFile.odt")
If you want to display something like an .odt or .doc then I don't thing Gambas can help you read the files but LibreOffice can convert those files to a text file, below converts the spreadsheet file 'temp.ods' to a 'csv' file: -
Dim sData as String
Dim sFolder as String = User.Home 'Change as necessary. The file name below in this case is temp.ods but could be Hello.xls
Shell "cd " & sFolder & " && " & "libreoffice --headless --convert-to csv temp.ods" Wait
sData = File.Load(sFolder &/ "temp.csv")
'You now have all the data from temp.ods in your variable sData!
NOTE: If LibreOffice is open then this trick wont work!-
- Posts: 195
- Joined: Tuesday 26th September 2017 3:17pm
- Location: NW England
Re: Viewing document files
Thank you Quincunxian, just what I needed.