条件:

  1. 安装好禅道的服务器
  2. 能直接浏览PDF的浏览器(或通过 安装插件实现 )
  3. 文档转换服务程序(建议部署在另一台服务器上)

 
 

实现 原理:

  1. 修改禅道的文件预览功能(OFFICE文档其使用的是下载打开方式)为向转换服务请求PDF
  2. 转换服务收到URL后,下载该文件并调用后台服务转换为PDF,向请求者返回PDF
  3. 禅道内置的预览PDF功能直接请求浏览器预览PDF

 
 

需要修改的文件及内容

xampp\zentao\module\file\control.php

xampp\zentao\module\file\view\printfiles.html.php

xampp\zentao\module\group\lang\resource.php

xampp\zentao\module\file\lang\zh-cn.php

 
 

control.php

 
 

增加方法

 
 

public function cloudview($fileID, $mouse = '')

{

$file = $this->file->getById($fileID);

 
 

/* Judge the mode, down or open. */

$mode = 'view';

$fileTypes = 'txt|jpg|jpeg|gif|png|bmp|xml|html|pdf|dwg';

if(stripos($fileTypes, $file->extension) !== false and $mouse == 'left') $mode = 'open';

        if($mode == 'open')

{

if(file_exists($file->realPath))$this->locate($file->webPath);

$this->app->triggerError("The file you visit $fileID not found.", __FILE__, __LINE__, true);

}

        else

if(file_exists($file->realPath))

{

$fileName = $file->title . '.' . $file->extension;

                $fileData = file_get_contents($file->realPath);

                $md5data=md5( $fileData);

$this->locate( 'http://192.168.118.136:9345/?url=' . common::getSysURL() . $file-> webPath . '&' . 'fileName=' . $fileName . '&' . 'md5=' . $md5data );

}

else

{

$this->app->triggerError("The file you visit $fileID not found.", __FILE__, __LINE__, true);

}

 
 

}

 
 

 
 

printfiles.html.php

 
 

修改方法downloadFile

新增方法viewFile

增加超链接指向

function downloadFile(fileID)

{

if(!fileID) return;

var sessionString = '<?php echo $sessionString;?>';

var url = createLink('file', 'cloudview', 'mfileID=' + fileID + '&mouse=left&mode=open') + sessionString;

    
 

window.open(url, '_blank');

return false;

}

 
 

function viewFile(fileID)

{

if(!fileID) return;

var sessionString = '<?php echo $sessionString;?>';

var url = createLink('file', 'cloudview', 'mfileID=' + fileID + '&mouse=left&mode=open') + sessionString;

      
 

window.open(url, '_blank');

return false;

}

 
 

增加链接

 
 

$fileTitle = "<li class='list-group-item'><i class='icon-file-text text-muted icon'></i> &nbsp;" . $file->title .'.' . $file->extension;

echo html::a($this->createLink('file', 'download', "fileID=$file->id") . $sessionString, $fileTitle, '_blank', "onclick='return viewFile($file->id)'");

echo "<span class='right-icon'>";

         common::printLink('file', 'download', "fileID=$file->id", "<i class='icon-download'></i>", '', "class='edit btn-icon' title='{$lang->file->download}'");

common::printLink('file', 'edit', "fileID=$file->id", "<i class='icon-pencil'></i>", '', "class='edit btn-icon' title='{$lang->file->edit}'");

if(common::hasPriv('file', 'delete')) echo html::a('###', "<i class='icon-remove'></i>", '', "class='btn-icon' onclick='deleteFile($file->id)' title='$lang->delete'");

echo '</span>';

echo '</li>';

 
 

resource.php

 
 

$lang->resource->file = new stdclass();

$lang->resource->file->download = 'download';

$lang->resource->file->cloudview = 'cloudview';

$lang->resource->file->edit = 'edit';

 
 

zh-cn.php

 
 

$lang->file->uploadImages = '多图上传';

$lang->file->cloudview = '云预览';

$lang->file->download = '下载附件';

 
 

 
 

执行效果

 
 

权限

 
 

 
 

附件管理

 

  

在禅道中实现WORD等OFFICE文档转换为PDF进行在线浏览的更多相关文章

  1. 转:C#实现office文档转换为PDF或xps的一些方法

    代码支持任意office格式 需要安装office 2007 还有一个office2007的插件OfficeSaveAsPDFandXPS 下载地址 [url]http://www.microsoft ...

  2. C#实现office文档转换为PDF或xps的一些方法( 转)

    源博客http://blog.csdn.net/kable999/article/details/4786654 代码支持任意office格式 需要安装office 2007 还有一个office20 ...

  3. C#实现office文档转换为PDF格式

    1.安装组件OfficeSaveAsPDFandXPS 需要安装office 2007 还有一个office2007的插件OfficeSaveAsPDFandXPS 下载地址   OfficeSave ...

  4. java使用jacob将office文档转换为PDF格式

    jacob 包下载地址: http://sourceforge.net/projects/jacob-project/ 下载后,将jacob 与 jacob-1.19-x64.dll放到安装jdk目录 ...

  5. office文档转pdf

    这里贴下代码吧,没啥好说的. using System; using System.Collections.Generic; using System.Linq; using System.Text; ...

  6. OFFICE 文档转换为html在线预览

    OFFICE 文档在线预览方案很多: 服务器先转换为PDF,再转换为SWF,最后通过网页加载Flash预览,比如flexpaper Office文档直接转换为SWF,通过网页加载Flash预览 微软的 ...

  7. Java实现web在线预览office文档与pdf文档实例

    https://yq.aliyun.com/ziliao/1768?spm=5176.8246799.blogcont.24.1PxYoX 摘要: 本文讲的是Java实现web在线预览office文档 ...

  8. Java实现office文档与pdf文档的在线预览功能

    最近项目有个需求要java实现office文档与pdf文档的在线预览功能,刚刚接到的时候就觉得有点难,以自己的水平难以在三四天做完.压力略大.后面查找百度资料.以及在同事与网友的帮助下,四天多把它做完 ...

  9. 把office文档转换为html过程中的一些坑

    之前和我们项目的团队一起酝酿了一个项目,公司的业务文档技术文档比较多,但都比较分散,虽然通过FTP或其他方式聚合起来了,但感觉还是不够方便. 另外公司每次都来新员工,新员工都需要一些培训,比较耗时,比 ...

随机推荐

  1. 理解CSS外边距margin

    前面的话   margin是盒模型几个属性中一个非常特殊的属性.简单举几个例子:只有margin不显示当前元素背景,只有margin可以设置为负值,margin和宽高支持auto,以及margin具有 ...

  2. setAttribute()

    ●节点分为不同的类型:元素节点.属性节点和文本节点等.   ●getElementById()方法将返回一个对象,该对象对应着文档里的一个特定的元素节点.   ●getElementsByTagNam ...

  3. Java学习之反射机制及应用场景

    前言: 最近公司正在进行业务组件化进程,其中的路由实现用到了Java的反射机制,既然用到了就想着好好学习总结一下,其实无论是之前的EventBus 2.x版本还是Retrofit.早期的View注解框 ...

  4. 理解 .NET Platform Standard

    相关博文:ASP.NET 5 Target framework dnx451 and dnxcore50 .NET Platform Standard:https://github.com/dotne ...

  5. PHP之GD函数的使用

    本文讲解常用GD函数的应用 1.一个简单的图像 我们先看一个例子: <?php $w = 200; $h = 200; $img = imagecreatetruecolor($w,$h); $ ...

  6. MFC单文档程序添加HTML帮助支持

    1.在App类 构造函数中添加 EnableHtmlHelp(); 2.在Frame类中,添加消息影射: ON_COMMAND(ID_HELP_FINDER, CFrameWnd::OnHelpFin ...

  7. (转载)linux下各个文件夹的作用

    linux下的文件结构,看看每个文件夹都是干吗用的/bin 二进制可执行命令 /dev 设备特殊文件 /etc 系统管理和配置文件 /etc/rc.d 启动的配置文件和脚本 /home 用户主目录的基 ...

  8. 完成C++不能做到的事 - Visitor模式

    拿着刚磨好的热咖啡,我坐在了显示器前.“美好的一天又开始了”,我想. 昨晚做完了一个非常困难的任务并送给美国同事Review,因此今天只需要根据他们提出的意见适当修改代码并提交,一周的任务就完成了.剩 ...

  9. 像黑客一样使用 Linux 命令行

    前言 之前在博客园看到一篇介绍 IntelliJ IDEA 配置的文章,它里面用的是 gif 动态图片进行展示,我觉得很不错.所以在我今天以及以后的博文中,我也会尽量使用 gif 动图进行展示.制作 ...

  10. WCF : 修复 Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service 问题

    摘要 : 最近遇到了一个奇怪的 WCF 安全配置问题, WCF Service 上面配置了Windows Authentication. IIS上也启用了 Windows Authentication ...