Page 1 of 1

Improve preview of MS Office documents

Posted: Mon Oct 26, 2015 5:37 am
by mkwong98
Hi, as the generation of pdf for preview is not 100% accurate, I suggest modifying the MS Add-on to generate the preview pdf if the MS Office support it and upload it at the same time as the document itself. I also suggest allowing the user to manually upload a preview pdf too. This way, it is possible to by pass the inaccurate preview pdf generation and use the pdf generated by MS Office. Thank you.

Re: Improve preview of MS Office documents

Posted: Wed Oct 28, 2015 7:15 am
by jllort
The solution you propose will not solve anything ( from openkm side you still need converting pdf to swf ). This topic is the same than another topic you have yet opened, I suggest do not open new topics for same issue and continues with the first opened.

Note: I'm not sure if community version has the option - at profiles - of embeded preview, what will use acrobat reader plugin in browser for previewing and will not cause to you the conversion problem. Take a look on profiles at general tab.

Re: Improve preview of MS Office documents

Posted: Wed Oct 28, 2015 10:55 am
by mkwong98
The problem that I have is that openoffice/libreoffice cannot render those files accurately to pdf to begin with:

1. the same formatting problem in the preview appears when I open those doc/xls/ppt files with openoffice/libreoffice.
2. pdf files generated by MS office do not have that problem and the preview of those pdf files also do no have the problem.

So the problem happens during the doc/xls/ppt to pdf step, and as far as I can tell, the converting pdf to swf works perfectly. That is why I propose to bypass openoffice/libreoffice if the computer uploading the file already has MS office.

So please reconsider my suggestion, thanks.

Re: Improve preview of MS Office documents

Posted: Thu Oct 29, 2015 8:31 am
by pavila
According to your proposal, how do we convert Office documents to PDF? The previewer need the document in PDF or SWF format.

Re: Improve preview of MS Office documents

Posted: Thu Oct 29, 2015 9:29 am
by mkwong98
I suggest two ways of doing it:
1. If it is uploaded using the MS Office add-on then automatically convert it to PDF at the same time as uploading the file
2. Allow the user to manually upload a PDF file to the preview cache

Re: Improve preview of MS Office documents

Posted: Fri Oct 30, 2015 7:21 pm
by jllort
If you want always want to make this conversion, the best option is create an automation action, and each time document is created in openkm, convert to pdf and delete word document. If you have Java skill I can guide on you for doing it.

Re: Improve preview of MS Office documents

Posted: Mon Nov 02, 2015 2:52 am
by mkwong98
I'll follow the development guide first to install the development tools. It will be great if you can tell me how the source code files are organized. Thank you.

Re: Improve preview of MS Office documents

Posted: Tue Nov 03, 2015 7:33 pm
by jllort
Here are some clues about it:
- You should create an action. Take a look for example the class named OMRDataCapture.java as scheleton for creating new action.
In the logic you should convert any document to pdf ( excepts pdf documents ), take a look at DocConverter.java there's a method named

Code: Select all

doc2pdf(File input, String mimeType, File output)
- You must download the file to server tmp ( take a look at FileUtils.createTempFile()) calling from the method getConted from OKMDocument.java API class:

Code: Select all

public InputStream getContent(String token, String docId, boolean checkout)
token should be null ( then is using user context )
docId can be document uuid or document path
checkout must be false

- From OKMDocument.java you can use other interesting methods like move or delete, etc...

Note: New actions must be registered into database, take a look at:
http://wiki.openkm.com/index.php/Enable_automation
http://wiki.openkm.com/index.php/Extend_automation_6.0
http://wiki.openkm.com/index.php/Automation

Re: Improve preview of MS Office documents

Posted: Sat Jul 23, 2016 12:57 pm
by OliviaBlogger
Thank you for the instruction. This really was good step.