How to preview word files through documents portlet like pdf files? - liferay

I have added the document portlet and to that a few pdf's and word files.
But when I click on pdf files they generate a preview, and the docx files don't. Why?
I want to preview the docx files also. Is there a method to achieve it?

Liferay makes use of OpenOffice/LibreOffice for deciphering MS-Office documents. You'll have to set up a connection to OpenOffice or LibreOffice (which has to run in server mode) in order to use it the way you want.

Related

Saving .doc files with MS Word through WebDAV not possible - no PUT request sent

I'm trying to implement a Node.js file server using the webdav-server npm module which works perfectly.
I'm able to open, edit and save .docx files with Microsoft Word (Microsoft® Word 2016 MSO (16.0.14228.20216) 32-Bit). As well as .odt files with LibreOffice Writer (Version: 7.0.6.2 (x64))
Capturing the requests made by Microsoft Word or LibreOffice Writer I detect the expected order GET - LOCK - PUT - UNLOCK representing the requests made by opening a file (GET), deactivating the readonly mode (LOCK), saving some changes (PUT) and closing the text editor application (UNLOCK).
However if I want to edit and save a .doc file with my Mircosoft Word application I see that there is not PUT request when saving the changes and therefore the changes are lost on closing the application. There is no feedback of any kind through MS Word when clicking the save button. Not that it saved the changes nor that it didn't.
On the other hand when I open the .doc files with LibreOffice Writer there is a PUT request as I'd expected it to be.
I also tried to switch the file type in the MS Word settings so it should use .doc to save files instead of .docx (default with MS Word 2016) but that didn't change anything.
Anyone knows what the problem could be? I don't get why the PUT request should not be sent by Microsoft Word for the .doc file type but for the .docx file type?
(It's a requirement of the project that it also works with .doc files, in the best case with LibreOffice and MS Word)
Thank you all in advance!

PolyAnalyst: Is there a way to read in the bookmarks of a PDF file?

I have a PDF with bookmarks. I tried to read it into PolyAnalyst but looks like it completely ignores the bookmarks. Is there a way to make PA keep the bookmarks of the file?
There currently is no method of extracting pdf bookmark metadata. You can, however, extract bookmark metadata from a Microsoft Word file.

How can I display xlsx file in an iframe

I need to display excel files(xls, xlsx) in an iframe.
Is this possible? If so, how would I do this?
Can't really be done. Excel files do not display natively in a browser. iframes, in this context, are just like regular pages. You would have to solve the showing Excel files in a browser problem first.
The closest you could get is to have a program that reads the Excel file and then generates HTML based on its content.
Adobe ColdFusion can do this natively; other languages and platforms may require 3rd party libraries.
Other solution would be to convert the file to pdf and display it in the iframe.

How to programmatically create MS Office .doc or .docx files on a linux server

In the past I've used catdoc for reading .doc files, but now I need to write them.
What is the best way to go about this? I don't need it to be perfect or fully featured.
a quick and dirty way would be, to write your file in HTML and save the file as .doc
Because word can open HTML you would have a Word File^^
Beware that if you open the file with word sometimes the "web-view-mode" is selected

Convert .xls to .pdf using LibreOffice via Command Line

I'm trying to convert a .xls file to .pdf using LibreOffice via command line on Ubuntu. I have a kind of report on the .xls file with some colors in the background of the cells and etc.
The problem is when I convert the .xls file, the .pdf loses the original format. Each page is broken almost in the half and the content of one page is displayed in two different pages.
Does anybody know how to convert the .xls file to .pdf via command line with keeping the original format?
Or some trick to set the size of the .pdf page to not break pages? (Also via command line)
The code I used to make the conversion was:
soffice --headless --convert-to pdf:"impress_pdf_Export" filename.xls
If you use LibreOffice to convert Microsoft Excel (XLS) files to PDF documents, this is a two-step process (even if your command does look like it is a one-step process):
Import the XLS into LibreOffice (even if started with --headless).
Export the PDF from LibreOffice.
If the result does not look like you expect (not similar enough to Excel's native PDF export), then start with debugging the first step from above:
Open the XLS file with LibreOffice in a GUI. Does it look like you expect it to look? Or are some formatting options looking weird?
Export the PDF from there (with the GUI). Are the page dimensions as you expect? Did you set them up how you prefer? The margins like you want them? etc.pp. ...
If you are working on Windows, you may also want to consider OfficeToPDF.exe. It is hosted on CodePlex, licensed with the Apache 2.0 License and available in binary and in source code.
It requires a working Office 2013, Office 2010 or Office 2007 installation. But then it can commandline- and batch-convert to PDF various MS Office-based file formats, including XLS(X), PPT(X), DOC(X), VSD(X) and PUB as well as Libre/OpenOffice-based ODT, ODS and ODC files.
Although this is a little bit off from the initial question (you don't _really need Office Libre if you have the Office suite and on a Windows machine)
I do appreciate the follow-up provided by Kurt. It prompted me to post the following Gist offering some clear instructions on how to go about using the .exe in a for loop.
https://gist.github.com/einsty/2189cae4175f619cff0f
Try copying appropriate font file (for me it's
a simsun.ttc file) to your libreoffice installing directory like '/opt/libreoffice4.2/share/fonts/truetype'.But if the width of a single excel sheet is too much for a print page(sth like 'A4'),it'll still collapse.

Resources