对于localhost使用WebODF编辑器 [英] Use WebODF editor for localhost
问题描述
如何添加 WebODF to localhost上的网站?
How to add WebODF to site on localhost?
我试图保存网页并在浏览器中打开,但它丢失了格式,一切都搞砸了。
I tried to save the webpage and opened in the browser but it looses formatting and everything is messed up.
推荐答案
我是从链接:
如何获取WebODF Go到WebODF.org并查看是否已经有满足您需求的
版本
直接在您的应用程序商店中搜索
< br>
或者下载WebODF的源代码并用它创建自己的应用程序。
这是源代码的链接: https://github.co m / kogmbh / WebODF / archive / master.zip
嗯,你呢很幸运,因为我使用的是基于Ubuntu的Linux发行版。以下是安装步骤:
Well, you're lucky, since I use a Linux distribution that is based on Ubuntu. Here are the steps to install:
创建webodf.js
webodf.js由以下网址编译:使用闭包编译器。这个编译器
压缩所有JavaScript文件,因此它们更小并且更快地执行
。 CMake用于设置构建系统,因此webodf.js可以是
创建如下:
Creating webodf.js
webodf.js is compiled by using the closure compiler. This compiler
compacts all JavaScript files, so that they are smaller and execute
faster. CMake is used to setup the buildsystem, so webodf.js can be
created like:
sudo apt-get安装cmake cmake-gui
sudo apt-get install git
git clone https:// github。 com / kogmbh / WebODF.git webodf
mkdir build
cd
build
cmake ../webodf
make webodf.js-target
这些命令不需要安装任何程序
您可以复制上面的命令(斜体),然后粘贴它们在终端(CTRL + ALT + T)中,如果一切运行成功,您应该在主目录中找到build
文件夹。打开它,你应该找到文件夹webodf
...再次打开它,在那里,你应该找到webodf.js
文件或类似内容...将其放在与HTML文件相同的目录中,并将其放在< head>
标记中:
sudo apt-get install cmake cmake-gui
sudo apt-get install git
git clone https://github.com/kogmbh/WebODF.git webodf
mkdir build
cd build
cmake ../webodf
make webodf.js-target These commands do not need the installation of any program
You can copy the commands above (in italic), and paste them in the Terminal (CTRL+ALT+T), if everything runs successfully, you should find the folderbuild
in your home directory. Open it up, you should find the folderwebodf
... Again, open it up, there, you should findwebodf.js
file or something like that... Put it in the same directory as your HTML file and at this to your<head>
tag:
<script src = "webodf.js" type="text/javascript" charset="utf-8"></script>
然后您可以按照描述这里。
我相信你只有需要以下程序: git 和 cmake ,无论如何,如果你需要任何其他程序,只需安装它,网上有很多说明。
要加载文件,请使用此 JavaScript :
I believe you only need the following programs : git and cmake, anyway, if you need any other, just install it, there are many instructions online.
To load a file use this JavaScript:
var odfelement = document.getElementById("odf");
/*
you should have a container with the id "odf"
For exmaple a <div>
*/
odfcanvas = new odf.OdfCanvas(odfelement);
odfcanvas.load("myfile.docx"); // the filename (don't forget the extension)
这是我们文档的容器,这里我们使用名为odf的 div
...
使用容器不是必需的,例如 odfelement < JavaScript中的/ code>变量可能只是我们的身体:
var odfelement = document.getElementsByTagName('body')[0];
,但结果更干净,无错误代码...此外,我只假设你可以这样做,所以保持安全并使用前一种方式。
And here is a container for our document, here we use a div
with the name "odf"...
Using a container isn't essential, for example the odfelement
variable in JavaScript could have just been our body like : var odfelement = document.getElementsByTagName('body')[0];
, but results in cleaner, bug-free code... In addition, I only assume that you could do that, so keep on the safe side and use the former way.
<div id="odf"></div>
注意
别忘了像我之前说的那样添加webodf的脚本:
Note
Don't forget to add webodf's script like I said before:
<script src="webodf.js" type="text/javascript" charset="utf-8"></script>
这篇关于对于localhost使用WebODF编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!