Moodle 3.6 and Converting docs for Annotating PDF

Re: Moodle 3.6 and Converting docs for Annotating PDF

by Ken Task -
Number of replies: 6
Picture of Particularly helpful Moodlers

Got the 'listener' configured/tested and running?

https://docs.moodle.org/35/en/Universal_Office_Converter_(unoconv)#Run_a_unoconv_listener

'spirit of sharing', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Moodle 3.6 and Converting docs for Annotating PDF

by Colin Fraser -
Picture of Documentation writers Picture of Testers

HI Ken, that link actually doesn't have one for Windows, and I am using a Windows VM. I created a batch file with this code: 

@"C:\Program Files (x86)\OpenOffice 4\program\python.exe" unoconv.py %*

I am using Open Office 4 as I use Libre Office on another VM I am running

And after Eloy's suggestion, went and made sure that the path to the unoconv.bat file was correct. But looking at the code, the batch file and the unoconv.py file are in the same folder, and I am now wondering if there should be an absolute path to the .py file rather than a relative path... going to test it now. 

EDIT: OK, the cron ran as it is supposed to and the batch file now has an absolute path to the unoconv.py file, and all the documentation says this should now work. So there has to be something I am missing. 

What I am thinking though is can all this be included in a single plugin? 

In reply to Colin Fraser

Re: Moodle 3.6 and Converting docs for Annotating PDF

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Another thought intrudes, AFAIK, The Dark Side tends to change the file structure of Word docs for each version of Office, subtle changes they may be, but changes none-the-less and usually sufficient that older word docs can open in newer versions, but newer word docs can't open in older versions of Word. Evil design, production and marketing, sure, but it is what it is. The docs I am trying to convert are all Office 2016, with unoconv v0.7.  That shouldn't be an issue, but I am asking. 

In reply to Colin Fraser

Re: Moodle 3.6 and Converting docs for Annotating PDF

by Ken Task -
Picture of Particularly helpful Moodlers

Don't use the 'Dark side' anything anymore ... the following references Linux used at the time which was CentOS 5 ... you have to adjust for the DS.  Like others, have decided that Google conversions are 'less problematic' so don't run this anymore.   The following from notes ...

Unoconv is a python script.   It is used to call the Office Suite you have installed in a 'headless' mode passes the document to be converted with command switches for the conversion.   The Office Suite executes a utility for such actions .... in Linux using LIbreOffice that is: libreoffice-headless-4.3.7.2-2.el6.x86_64.rpm.

You can test the conversion outside of Moodle .... via command line.

You have to upload one of your .docx's to a work directory of some sort.

Commnad in Linux is kinda self-explanatory ...

unoconv -f pdf hp-unoconvtest.docx

-f working with a file.

desire conversion to a pdf file.

The document to convert is hp-unoconvtest.docx

This will output, if it executes on DS, in the same directory.

And use hp-unoconvtest as it's filename ... hp-unoconvtest.pdf

In your DS GUI one should be able to double click on hp-unoconvtest.pdf and that should use whatever your DS system has for viewing PDF's.

If I re-call correctly, on the systems I had this running upon, had to manually edit unoconv to avoid a conflict

[root@visdmoodle bin]# head unoconv
#!/usr/bin/env python
### !/usr/lib64/libreoffice/share/Scripts/python
### original !/usr/bin/env python
(note the server visdmoodle no longer exist)

Here: https://github.com/dagwieers/unoconv
Section on Python and pyuno incompatibilities

There are some trouble shooting tips.

Python and pyuno incompatibilities

Beware that the pyuno python module needs to be compiled with the exact same version of python that you are using to load it. A lot of people that run into problems loading pyuno are actually using a precompiled LibreOffice that they downloaded somewhere and is incompatible with the python version on their system.

Dunno how all that translates to DS.

'spirit of sharing', Ken



In reply to Ken Task

Re: Moodle 3.6 and Converting docs for Annotating PDF

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Thanks Ken, I suspect the last part is right..

C:\Program Files (x86)\OpenOffice 4\program\python-core-2.7.6: can't open file 'C:\Program': [Errno 2] No such file or directory

Then went and edited the file to remove the absolute path and this happened...

C:\Program Files (x86)\OpenOffice 4\program\python-core-2.7.6: can't open file 'C:\Program': [Errno 2] No such file or directory

So went back to the original setting and this... 

C:\Program Files (x86)\OpenOffice 4\program\python-core-2.7.6: can't open file 'unoconv\unoconv.py': [Errno 2] No such file or directory

Then had a look at the PATH statement... so now I suspect I am banging the wrong gong. 

PATH=C:\Program Files (x86)\unoconv\;C:\Program Files\ImageMagick;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\xampp\;C:\WINDOWS\System32\OpenSSH\;C:\xampp\python\Scripts\;C:\xampp\python\;C:\Users\Colin\AppData\Local\Microsoft\WindowsApps;
C:\Users\Colin\AppData\Local\GitHubDesktop\bin

I am using the Apache Friends version of Xampp and installed Python for another project, so likely there is a conflict. Going to uninstall the Python before going any further. Also, there is nothing in the path to Open Office either...mmmm would there need to be? 

In reply to Colin Fraser

Re: Moodle 3.6 and Converting docs for Annotating PDF

by Colin Fraser -
Picture of Documentation writers Picture of Testers

Well, that didn't work either... 

It's that same error over and over, "No such file or directory." I've tried every combination of paths I can think of and it is just not finding it. So perhaps moving the unconv.py and .bat into the Open Office python folder...

Shouldn't have to, but... moved the file into the unoconv folder and it converted properly. Tried again in a different directory same error so the path is the #1 suspect.  But why? 

In reply to Colin Fraser

Re: Moodle 3.6 and Converting docs for Annotating PDF

by Ken Task -
Picture of Particularly helpful Moodlers

Why you ask? It's WindBloz!!!!   (Note: if you can use 'Crapple' ... then I can use WindBloz!!!!)

Ok, enough bashing ....

https://github.com/dagwieers/unoconv

The section entitled: Python and pyuno incompatibilities

Provides examples and mentions setting the UNO_PATH as well as examples using unoconv conversion to PDF from .odt files.

'spirit of sharing', Ken