Some pitfalls in Converting office documents to html,
Previously, we developed a project with our project team. The company has many business documentation and technical documents, but all of them are scattered. Although they are aggregated through FTP or other methods, however, it is not convenient enough.
In addition, every time the company comes to a new employee, the new employee needs some training, which is time-consuming. The better way is to record the previous configuration video and then show it to the new employee offline, but it takes a long time, materials or videos cannot be found or are not up-to-date.
So our team thought about a project to put the existing materials and videos offline, that is, to watch office materials and videos online through a website. In addition, you can also evaluate data and like data, and decide whether to organize and communicate with new employees or old employees based on data such as like or want to learn.
The initial project was to refer to Baidu Library and convert Office data to flash. The video data was stored directly and then watched online through the website. The flashpager software was used. The general code is as follows:
String converter = pt.getFlashPaperUrl() + "/FlashPrinter.exe -o " + savePath + swfName + ".swf " + documentName;Process p = pro.exec(converter);
Execute flashprinter.exe with process, and then pass the command and the file to be converted.
However, the company went to windows and Microsoft Office. This exe can only run in windows, so I changed the method and automatically converted the office document to Html in linux.
Because Microsoft's office cannot be used, I chose openoffice. I downloaded openoffice4.0.1 locally and started the listener after installation:
Soffice-headless-accept = "socket, host = 127.0.0.1, port = 8100; urp;"-nofirststartwizard &
The JAVA code can connect to port 8100 so that openoffice can help us convert office documents to Html.
The Code is as follows:
OpenOfficeConnection con = new SocketOpenOfficeConnection ("127.0.0.1", 8100); con. connect (); // create the converter DocumentConverter converter = new OpenOfficeDocumentConverter (con); // The conversion document asks html converter. convert (docFile, htmlFile); // close the openoffice connection con. disconnect ();
In this way, the office document is converted into an html file: htmlFile.
However, by default, a ppt is converted into an html file. An image is generated for each page of ppt, and an html file is displayed on the previous page of the next page. We hope to display the html directly to all the ppt pages. After a slight transformation, we converted the ppt file to all the images in the html folder for training and then spliced an html file:
<br><center></center>
After the development is complete, it is found to be perfect.
However, we still encountered two pitfalls, which were not found long after analysis.
1. Html conversion from some ppt files is always garbled.
2. converting some Word documents to html is always blank.
The above two problems have been tossing around for a long time, and the problematic office is always faulty. If there is no problem, the office can be converted successfully, and the problem can only be found after a long analysis.
After a page of ppt, you can delete and convert the text one by one.
In the first issue, if there are remarks in the ppt that are converted to html through openoffice, it will be garbled and there will be little content.
The second problem is that some text in the Word document is copied to the openoffice document, which may be caused by incompatibility of the text font. For example, when wps opens the word, it can see that it is all, but copying the text to openoffice found that there are several words not.
Solution:
The first problem is to manually delete all the notes of the ppt, and the conversion will be successful.
The second simple solution is to change the font of all texts to the same font, for example, to.
Hope to bring help to other think-like method or encounter the same problem, reprint please indicate from: http://lawson.cnblogs.com