April 6, 2009

Fix for KnowledgeTree online document viewer plugin

Filed under: Tips — Tags: , — Webopius @ 2:23 pm

Something new this week… Document Management

Webopius is currently working on a project for a client where we need to create a managed, secure repository of documents online. We needed to handle document version control, document workflow and approvals along with online viewing.

Possible solutions included Microsoft Office Sharepoint Server and a number of commercial solutions. In the end, we chose the excellent Open Source document management solution Knowledge Tree.

KnowledgeTree can run on a Unix or Windows platform and contained all the functionality we were looking for in this project. We had it up and running within about an hour.

Online viewing of documents

Although KnowledgeTree does contain a PDF generator, one feature we needed was the ability to view documents within the browser without having to download them. After a brief search we chose the Wemag plugin.

Unfortunately at this point we hit a snag when using a Windows server. For some reason the plugin was showing within KnowledgeTree but when you clicked on ‘View Online’ all that appeared was a blank page.

After some digging, the issue seemed to be related to the use of the php exec() command within the plugin.

The Solution

To fix this issue, you need to edit the PdfToSwfConvertor.php file that you’ll find in [your KnowledgeTree installation directory] / knowledgeTree / plugins / WemagOnlineDocumentViewer directory.

Here are the lines to change:

PdfToSwfConverter::writeLog(exec(KT_DIR."/plugins/WemagOnlineDocumentViewer/pdf2swf/pdf2swf.exe $src $destination"));

To something like this...

$ex = '"'.KT_DIR.'/plugins/WemagOnlineDocumentViewer/pdf2swf/pdf2swf.exe" '.$src.' "'.$destination.'"';
PdfToSwfConverter::writeLog("running ".$ex); //optional but useful for debugging, repeat below if needed.
`"$ex" 2>&1`;

And this line..

PdfToSwfConverter::writeLog(exec(KT_DIR."/plugins/WemagOnlineDocumentViewer/pdf2swf/swfdump.exe $destination",$output));

To this...

 $ex = '"'.KT_DIR.'/plugins/WemagOnlineDocumentViewer/pdf2swf/swfdump.exe" ' . '"'.$destination.'"';
PdfToSwfConverter::writeLog("running ".$ex);
   `"$ex" 2>&1`;

And this line...

PdfToSwfConverter::writeLog(exec(KT_DIR."/plugins/WemagOnlineDocumentViewer/pdf2swf/swfcombine.exe -X $width -Y $height \"".KT_DIR."/plugins/WemagOnlineDocumentViewer/pdf2swf/swfs/wemag_viewer.swf\" viewport=\"$destination\" -o \"$destination\""));

To this...

$ex = '"'.KT_DIR.'/plugins/WemagOnlineDocumentViewer\pdf2swf\swfcombine.exe"  -X '.$width.' -Y '.$height. ' "'.KT_DIR.'/plugins/WemagOnlineDocumentViewer/pdf2swf/swfs/wemag_viewer.swf" viewport="'.$destination.'" -o "'.$destination.'"';
`"$ex" 2>&1`;

 

Now, you should be able to view documents online and navigate through the pages.

  • Tags