Fix for KnowledgeTree online document viewer plugin
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.
























Hello,
Came across this post coz I was having similar issues with knowledgetree displaying a blank screen rather than the document itself. I have followed your advice above but cant seem to get it to work. Strangely I cant seem to find any other forums discussing this issue. I am running my KT on Ubuntu 9.04 Desktop. Hope you can give me more pointers on this since I am not very educated in PHP. Thanks in advance and hoping to hear from you.
Comment by Morgan — June 18, 2009 @ 1:08 pm
Well lots of testing and I finally found what was the issue…..the wemagonlinedocuments folder in the var directory was not set with the right permissions….chmod 0777 it and the swf file is created without any issues….hope this helps out some noobs like myself on linux….thanks for the platform to post this…..
Comment by Morgan — June 18, 2009 @ 1:25 pm
Hi Morgan,
Glad to hear you got it working and thanks for posting your solution here.
Comment by Webopius — June 18, 2009 @ 3:28 pm
Hi,
I have installed the “[b]WEMAG ONLINE DOCUMENT[/b]” plugin .
When I click on view online option,I do not see the content of document,though i can see the Documentviewer with scroll-bar.
1).I have kept the wemagonlinedocuments folder in var
2).I placed the WemagOnlineDocumentViewer folder in the plugins folder.
3). I changed the code as you have mentioned above.
No Error, But document not getting displayed on clicking “View Online”
Please Tell me what to do …
Comment by vivek — April 19, 2010 @ 7:14 am
Hi,
To use this plugin, you need to install swftools on you server.
Victor Salas
Comment by Victor — December 23, 2010 @ 9:36 am