javascript - 对本地主机使用 WebODF 编辑器

标签 javascript

如何添加WebODF到本地主机上的站点吗?

我尝试保存网页并在浏览器中打开,但格式丢失,一切都乱了。

最佳答案

我从 link 得到这个你实际上给了:

How to get WebODF Go to WebODF.org and see if there is already a version meeting your needs

Search for it directly in your app store

Or download the sourcecode of WebODF and create your own application with it.


这是源代码的链接:https://github.com/kogmbh/WebODF/archive/master.zip

更新

嗯,你很幸运,因为我使用的是基于 Ubuntu 的 Linux 发行版。以下是安装步骤:

创建 webodf.js
webodf.js 使用闭包编译器进行编译。这个编译器 压缩所有 JavaScript 文件,使它们更小并执行 快点。 CMake 用于设置构建系统,因此 webodf.js 可以 创建如下:

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 folder build in your home directory. Open it up, you should find the folder webodf... Again, open it up, there, you should find webodf.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>

然后您可以按照描述使用 WebODF here .

更新2

我相信你只需要以下程序:gitcmake,无论如何,如果你需要任何其他程序,只需安装它即可,网上有很多说明。
要加载文件,请使用此 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)

这是我们文档的容器,这里我们使用 div名字叫“odf”... 使用容器不是必需的,例如 odfelement JavaScript 中的变量可能只是我们的 body ,如: var odfelement = document.getElementsByTagName('body')[0]; ,但会产生更干净、无错误的代码...此外,我只假设您可以做到这一点,因此请保持安全并使用前一种方式。

<div id="odf"></div>

注意

不要忘记像我之前所说的那样添加 webodf 的脚本:

<script src="webodf.js" type="text/javascript" charset="utf-8"></script>

关于javascript - 对本地主机使用 WebODF 编辑器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23501951/

相关文章:

javascript - SVG 蒙版和悬停动画

javascript - 使用 Javascript 循环浏览 Outlook 电子邮件

javascript - CSS3 转换导致屏幕闪烁或字体别名

php - 如何在php文件中使用jquery?

javascript - 在 div 内的页面加载时显示微调图像,并在页面完全加载到 div 内时隐藏微调图像

php - 如何通过 OAuth 登录以便 cron 作业可以运行

javascript - 为什么我需要在一个函数中有两个返回值?

javascript - 访问类函数?

javascript - 顶级函数中的 "this"

javascript - 如何在javascript中使用定时器?