条件:

  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. alias导致virtualenv异常的分析和解法

    title: alias导致virtualenv异常的分析和解法 toc: true comments: true date: 2016-06-27 23:40:56 tags: [OS X, ZSH ...

  2. [BOT] 一种android中实现“圆角矩形”的方法

    内容简介 文章介绍ImageView(方法也可以应用到其它View)圆角矩形(包括圆形)的一种实现方式,四个角可以分别指定为圆角.思路是利用"Xfermode + Path"来进行 ...

  3. ABP文档 - Javascript Api - Message

    本节内容: 显示信息 确认 Message API给用户显示一个信息,或从用户那里获取一个确认信息. Message API默认使用sweetalert实现,为使sweetalert正常工作,你应该包 ...

  4. RestTemplate发送请求并携带header信息

    1.使用restTemplate的postForObject方法 注:目前没有发现发送携带header信息的getForObject方法. HttpHeaders headers = new Http ...

  5. WebGIS中等值线前端生成绘制简析

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 等值线是GIS制图中常见的功能,一般有两种思路:一种是先进行插 ...

  6. C++随笔:.NET CoreCLR之GC探索(2)

    首先谢谢 @dudu 和 @张善友 这2位大神能订阅我,本来在写这个系列以前,我一直对写一些核心而且底层的知识持怀疑态度,我为什么持怀疑态度呢?因为一般写高层语言的人99%都不会碰底层,其实说句实话, ...

  7. await and async

    Most people have already heard about the new “async” and “await” functionality coming in Visual Stud ...

  8. C++ 11 多线程--线程管理

    说到多线程编程,那么就不得不提并行和并发,多线程是实现并发(并行)的一种手段.并行是指两个或多个独立的操作同时进行.注意这里是同时进行,区别于并发,在一个时间段内执行多个操作.在单核时代,多个线程是并 ...

  9. javascript运动系列第一篇——匀速运动

    × 目录 [1]简单运动 [2]定时器管理 [3]分享到效果[4]移入移出[5]运动函数[6]透明度[7]多值[8]多物体[9]回调[10]函数完善[11]最终函数 前面的话 除了拖拽以外,运动也是j ...

  10. kali linux下的arp攻击

    这是我第一篇博客,写的不好请谅解 ____________________________(分割线)_______________________________ 在kali linux系统下自带工具 ...