unoconv - converting docx and similar documents - Windows Installation Problems

658 views
Skip to first unread message

Robert Damrau

unread,
Jun 29, 2013, 5:34:13 AM6/29/13
to resour...@googlegroups.com
Hi,

for some time now i am trying to get unoconv to work with a windows setup.
Unoconv is actually working but not with integration to RS.

I installed Libre Office, set a PATH variable for the system to know where python is located, set UNO_PATH for unoconv to know where Libre Office is.
I set $unoconv_path in config.php to point to the unoconv python script.
I changed in preview_preprocessing.php:

global $unoconv_extensions;
if (in_array($extension,$unoconv_extensions) && isset($unoconv_path) && !isset($newfile))
{
$unocommand="python ". $unoconv_path . "/unoconv";
#if (!file_exists($unocommand)) {exit("Unoconv executable not found at '$unoconv_path'");}
run_command($unocommand . " --format=pdf " . escapeshellarg($file));
$path_parts=pathinfo($file);
$basename_minus_extension=remove_extension($path_parts['basename']);
$pdffile=$path_parts['dirname']."/".$basename_minus_extension.".pdf";
if (file_exists($pdffile))

I changed in general.php:

Line 90:

# Fetching the file path? Add the full path to the file
$filefolder=$storagedir . "" . $folder;

I removed the "/" from the path as unoconv wasn't able to recognize path with"//" in it.


Now when i try to update previews with an existing docx i get the following log:

2013-06-29 09:11:06 Starting preview preprocessing. File extension is docx.
2013-06-29 09:11:06 CLI command: python D:\web\unoconv/unoconv --format=pdf "D:\web/apps/resourcespace/htdocs/filestore/3_2f513a34a2ffd64/3_bdb92bae5259160.docx"
2013-06-29 09:11:06 CLI command: unzip -p "D:\web/apps/resourcespace/htdocs/filestore/3_2f513a34a2ffd64/3_bdb92bae5259160.docx" "docProps/thumbnail.jpeg" > D:\web/apps/resourcespace/htdocs/filestore/3_2f513a34a2ffd64/3_bdb92bae5259160.jpg
2013-06-29 09:11:06 create_previews(ref=3,thumbonly=,extension=jpg,previewonly=,previewbased=,alternative=-1)
2013-06-29 09:11:06 SQL: update resource set file_checksum='' where ref='3'
2013-06-29 09:11:06 SQL: update resource set preview_tweaks = '0|1' where ref = '3'
2013-06-29 09:11:06 File source is D:\web/apps/resourcespace/htdocs/filestore/3_2f513a34a2ffd64/3_bdb92bae5259160.jpg

But no pdf is created.

Now when i just copy and paste the cli command from the log 
python D:\web\unoconv/unoconv --format=pdf "D:\web/apps/resourcespace/htdocs/filestore/3_2f513a34a2ffd64/3_bdb92bae5259160.docx"
into cmd voila it works! The pdf is generated inside the folder. 

Has anyone a clue what i'm doing wrong? Has anyone EVER succesfully get unoconv to work with windows?


Thanks for any help on this!



Robert

Robert Damrau

unread,
Jun 30, 2013, 6:50:42 AM6/30/13
to resour...@googlegroups.com
Defining the path to python.exe explicitly did the trick:

global $unoconv_extensions;
if (in_array($extension,$unoconv_extensions) && isset($unoconv_path) && !isset($newfile))
{
$unocommand="D:\LibreOffice\program\python.exe ". $unoconv_path . "/unoconv";
#if (!file_exists($unocommand)) {exit("Unoconv executable not found at '$unoconv_path'");}
run_command($unocommand . " --format=pdf " . escapeshellarg($file));
$path_parts=pathinfo($file);
$basename_minus_extension=remove_extension($path_parts['basename']);
$pdffile=$path_parts['dirname']."/".$basename_minus_extension.".pdf";
if (file_exists($pdffile))

Robert Damrau

unread,
Jun 30, 2013, 7:35:10 AM6/30/13
to resour...@googlegroups.com
I would like to suggest adding this to the source so unoconv works with windows.

New in config.php: $pythonpath

in preview_preprocessing something like this: (?)

Index: preview_preprocessing.php
===================================================================
--- preview_preprocessing.php (revision 4558)
+++ preview_preprocessing.php (working copy)
@@ -5,7 +5,7 @@
 # for example types that use GhostScript or FFmpeg.
 #
 
-global $imagemagick_path, $imagemagick_preserve_profiles, $imagemagick_quality, $imagemagick_colorspace, $ghostscript_path, $pdf_pages, $antiword_path, $unoconv_path, $pdf_dynamic_rip, $ffmpeg_audio_extensions, $ffmpeg_audio_params, $qlpreview_path,$ffmpeg_supported_extensions, $qlpreview_exclude_extensions, $ffmpeg_global_options,$ffmpeg_snapshot_fraction, $ffmpeg_snapshot_seconds;
+global $imagemagick_path, $imagemagick_preserve_profiles, $imagemagick_quality, $imagemagick_colorspace, $ghostscript_path, $pdf_pages, $antiword_path, $unoconv_path, $pythonpath, $pdf_dynamic_rip, $ffmpeg_audio_extensions, $ffmpeg_audio_params, $qlpreview_path,$ffmpeg_supported_extensions, $qlpreview_exclude_extensions, $ffmpeg_global_options,$ffmpeg_snapshot_fraction, $ffmpeg_snapshot_seconds;
 global $dUseCIEColor;
 
 # Locate utilities
@@ -316,9 +316,11 @@
 global $unoconv_extensions;
 if (in_array($extension,$unoconv_extensions) && isset($unoconv_path) && !isset($newfile))
  {
- $unocommand=$unoconv_path . "/unoconv";
- if (!file_exists($unocommand)) {exit("Unoconv executable not found at '$unoconv_path'");}
-
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
+ $unocommand=$pythonpath . "\python.exe ". $unoconv_path . "/unoconv";
+ else
+ $unocommand=$unoconv_path . "/unoconv";
+ if (!file_exists($unoconv_path . "/unoconv")) {exit("Unoconv executable not found at '$unoconv_path'");}
  run_command($unocommand . " --format=pdf " . escapeshellarg($file));
  $path_parts=pathinfo($file);
  $basename_minus_extension=remove_extension($path_parts['basename']);


What do you think?
Reply all
Reply to author
Forward
0 new messages