General developer forum

Moodle 3.6 and Converting docs for Annotating PDF

 
moi!!! it is what is is...
Moodle 3.6 and Converting docs for Annotating PDF
Documentation writersParticularly helpful Moodlers

I'm not sure if I have missed something, but according to this Moodle Doc on using Unoconv in Windows 10/Xampp configuration, there should be a path somewhere to connect the converter. I have the CLI, the du, the dot paths and ticks for Aspell, Ghostscript and Python, but I don't see a path statement for unoconv. Yet the Moodle doc says: 

     Set pathtounoconv to the batch file created above (C:\unoconv\unoconv.bat)

Oh? And where is that set, not in Site Admin > Server > System Paths, 

I understood the the non-pdf document conversion to pdf was undertaken by the Cron, so went into Scheduled tasks and checked to see of the task was enabled, yes, that's good. I then checked if the cron was actually working and no, it wasn't. After a bit of finessing, I got the Cron working, but when I go to a non-pdf doc in the Assignment and prepare it for annotation, it is just not converting. I am assuming that there is to be a connection here, but how is that connection made in v3.6. I seem to recall I got this working in a past version, but too long ago and I no longer have access to the notes I made at that place. 

btw, the Annotation using Ghostscript works, I have even added a couple of stamps of my own, and that all works nicely, but the conversion from a doc to a pdf for annotation is just not working. The Moodle docs are not helpful here...  Any ideas? 

 
Average of ratings: -
Picture of Jerry Lau
Re: Moodle 3.6 and Converting docs for Annotating PDF
 

do you have soffice running? if so kill it

 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle 3.6 and Converting docs for Annotating PDF
Documentation writersParticularly helpful Moodlers

No definitely not running, well maybe not, erm... thanks Jerry, the documentation I had suggests soffice is likely to be looking for updates so change the settings, I'm sure I did, but will look in the morning... 

@Eloy, no I haven't, will check asap... should get time to look in the morning... but will let you know soon as, 

Thanks for the tips, gentlemen, really appreciate it. 

 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle 3.6 and Converting docs for Annotating PDF
Documentation writersParticularly helpful Moodlers

OK, Open Office has been blocked in the firewall, so is not looking out for updates or upgrades and the Tools > Options > Open Office > Online Updates option is not even appearing in the menu, so not sure what's going on there. And yes, I do install as Admin when installing things, always.  I have uploaded both Word docx and OpenOffice odt files, the same file in two different formats, to test and...

Error logs have now been properly configured, and are not generating errors on this, the cron is properly running and the Scheduled task worked, well it didn't report an error...

The last run of the cron 

There is nothing wrong at that end. So is there some other obscure setting that needs be made in PHP or somewhere else in Moodle that needs to be made? 

I have frequently used Annotations, and that is really what I was referring to earlier, set them up like I have here and got them working. I am now questioning if my interpretation of the idea of converting entire documents from non-PDF format to PDF in Moodle for annotation is actually right?  Or am I just getting it entirely wrong? Is there a way to annotate uploaded documents without having to convert that pursuing this is a waste of time?    

 
Average of ratings: -
Picture of Ken Task
Re: Moodle 3.6 and Converting docs for Annotating PDF
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: -
moi!!! it is what is is...
Re: Moodle 3.6 and Converting docs for Annotating PDF
Documentation writersParticularly helpful Moodlers

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? 

 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle 3.6 and Converting docs for Annotating PDF
Documentation writersParticularly helpful Moodlers

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. 

 
Average of ratings: -
Picture of Ken Task
Re: Moodle 3.6 and Converting docs for Annotating PDF
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



 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle 3.6 and Converting docs for Annotating PDF
Documentation writersParticularly helpful Moodlers

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? 

 
Average of ratings: -
moi!!! it is what is is...
Re: Moodle 3.6 and Converting docs for Annotating PDF
Documentation writersParticularly helpful Moodlers

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? 

 
Average of ratings: -
Picture of Ken Task
Re: Moodle 3.6 and Converting docs for Annotating PDF
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



 
Average of ratings: -
Picture of Jerry Lau
Re: Moodle 3.6 and Converting docs for Annotating PDF
 

what do your error logs or logs indicate?

 
Average of ratings: -
One poor developer...
Re: Moodle 3.6 and Converting docs for Annotating PDF
Core developersDocumentation writersMoodle HQPlugin developersTesters

Oh? And where is that set, not in Site Admin > Server > System Paths,

Have you tried looking for "pathtounoconv" in the admin page?

As far as unoconv in a document converter plugin... it should be under Site administration / Plugins/ Document converters. (aka yoursite/moodle/admin/category.php?category=fileconverterplugins)

Ciao smile

 
Average of ratings: -