Is there a component or plugin for the latest TiNG that will allow me to display a Word Docx that is stored in a BLOB/Media field?
In my solution I am allowing my client to store attachments that could be any file type, but most likely images, PDFs or Office documents.
I have a button that they can then click to view in a dialog a preview of the file, so currently I switch between showing a dialog with an ‘Image’ component or one with the svyPDF(JS)Viewer depending on file type, but they also want to see their Word files and can’t see any way of doing that…
Thanks
s.wolf:
Hi Rafi,
we use the it2be_word- and it2be_data-plugins for that:
create a temp file of your document / workbook (plugins.file) from the database
open your file with it2be-plugins (word-plougin for word, data-plugins for excel)
save the opened document / workbook as temp pdf-file (the plugins can do this)
read the new tempfile into a variable, you use as dataprovider for a servoy pdf viewer and show it there
You have to use the file-plugin, because the tempfiles will be needed on the server, as the plugins work there.
This is one way we use, to show a preview of word- and excel-documents in our solution.
Silvio
Thanks for your reply, but that seems like a lot of work to just preview a document
I will think about it though…
Although it seems a lot of work, the solution that Silvio supplied does always work. Either for solutions running internally on the client’s network or being a saas-application.
Besides, you are in control and documents remain on the server.
If your solution is accessible over the internet there might be another option.
You have to use the PDF viewer component for that (not the PDFjs one) and set the documentURL property to something like this.
var _jsFile = plugins.file.convertToJSFile('myFilePath');
var _sURL = "https://docs.google.com/gview?url=" + _jsFile.getRemoteUrl() + "&embedded=true"
elements.pdfviewer.documentURL = _sURL
As you can see, much easier but with sidenotes:
this only works when _jsFile.getRemoteUrl() returns a URL that is publicly accessible as Google needs to fetch that.
bear in mind that you will use Google to convert this for you, no idea where your data ends up and what it’s being used for
Thanks Marc, so helpful as always!
I don’t think my client would be happy to have their documents available on the Internet, or being passed thru Google docs
But useful code anyway…
Thanks
I tried this:
excelWorkBook.save(zielDateiNamePDF, 13);
since 13 seems to be the type PDF according to the aspose-library, bit I only got an error, same when ommiting the type.
Hi Robert,
for word you can use the type given in the plugin: plugins.it2be_word.DOCUMENT_FORMAT.PDF
For excel you have to create a temp file and do something like
var loExcel = plugins.it2be_data.createExcel()
var loWorkbook = loExcel.readWorkBook(PathToTempXLSX)
loXLS.writeWorkBook(loWorkbook,PathForPDF+PDFfileName)