[3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

[3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Jeff Noel -
Number of replies: 12

I've been testing back and forth with different python and unoconv versions to debug this issue.


Right now:
Unoconv 0.8.2 with Python 3.5.5

Windows Server 2016

Conversion works fine from CLI on Windows. On Moodle, it's always a blank page when converting .docx document to .pdf for feedback and annotation.

The Moodle scheduled task runs fine and does not display any error... but all files generated are 1 blank page, everytime. Here's what the logs tell:

Execute scheduled task: Préparer les travaux remis pour annotation (assignfeedback_editpdf\task\convert_submissions)
... started 13:48:29. Current memory use 38.7Mo.
Convert 1 submission attempt(s) for assignment 16437
... used 134 dbqueries
... used 2.4809911251068 seconds
Scheduled task complete: Préparer les travaux remis pour annotation (assignfeedback_editpdf\task\convert_submissions)


The unoconv path test works correctly, but the test PDF file is a 0 bytes .pdf file somehow.


I'm trying to find ways to get an error message or something to help me debug this issue, as it's on my production server right now.

I'm so tired to trying to make this work that I looked into the Google Drive Converter, but I really don't want to jump into this while in the middle of the semester (domain validation, etc.). So if I could get unoconv to work as it should, I'd be really happy.


Any help will be greatly appreciated.

Average of ratings: -
In reply to Jeff Noel

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The best advice I can give you is to give up. Use Google Docs instead. Unoconv is nowhere near stable enough for production use. 

Having said that, most problems are down to permissions. Remember that unoconv will run as the web server user and needs to have permissions to create temporary files and directories. This is in whatever that user's home directory is on Linux. I have no idea about Windows. 

Average of ratings: Useful (1)
In reply to Howard Miller

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Jerry Lau -

do you have a link on how to do it using google docs if we already want to move away from unoconv that we are using at the moment?

thanks

In reply to Jerry Lau

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Ken Task -
Picture of Particularly helpful Moodlers

Site administration
Plugins
Document converters
Manage document converters

https://docs.moodle.org/35/en/Google_Drive_converter

'spirit of sharing', Ken


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

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Jerry Lau -

Is this for a specific course only or when a google account is created, is it set for global use in moodle?

In reply to Jerry Lau

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Ken Task -
Picture of Particularly helpful Moodlers

Hmmm ... just noticed ... this thread for Windows ... you don't run Windows, do you Jerry?  So this is a 'piggy-back' ... :\   ROTFL!

From the config screen for document converters looks to be a global and not a per course setting.  Don't run a site with both turned on.   Try it and let us know how that went!  more ROTFL!

'spirit of sharing', Ken


In reply to Howard Miller

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Jeff Noel -
I don't know if you guys will be able to help me with that, but I've been able to fix my problem... to encounter another one.


I fixed the issue with unoconv not getting called properly. On Windows 64-bit, you need to do this: 

https://github.com/dagwieers/unoconv/issues/473


Now, there's an issue with is_minimum_version_met() in the following Moodle file:


files/converter/unoconv/classes/converter.php


The exec() function called on line 244 does not give any result, and $output merely contains the content of unoconv.bat (with the parameters sent). ie.:


C:\inetpub\wwwroot\files\converter\unoconv>;python c:\unoconv\unoconv.py --version

It never contains the result (which outputs the following and works just fine):

unoconv 0.8.2
Written by Dag Wieers <dag@wieers.com>
Homepage at http://dag.wieers.com/home-made/unoconv/

platform nt/win32
python 3.5.5 (default, Jan 31 2019, 00:04:27) [MSC v.1900 64 bit (AMD64)]
LibreOffice 6.1.5.2

In the end, I always get the error telling me that I don't meet the requirements for the minimum version.


If anybody has a clue on how to get the exec() function to receive the .bat's full echoed content, I'd be really happy.
I wonder if this is worth a ticket in the bug tracker, since it's only partly related to Moodle.

Average of ratings: Useful (1)
In reply to Jeff Noel

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Jeff Noel -

I got it to pass the test successfully but passing the command manually on line 244

exec("c:\unoconv\unoconv.py --version",$output);
The test PDF is still blank though. I'm working on trying to find the suitable permissions. Somebody got it to work by putting the Application Pool User as LocalSystem, but it's basically root. I can't do that. Trying to find another way. Any tips appreciated.
In reply to Jeff Noel

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Jeff Noel -

I tried switching to Local System as the Application Pool user on my test server and it changed nothing, the issue remains.

In reply to Howard Miller

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Jeff Noel -

We cannot fall back to Google Drive as there's a confidentiality problem with the academic files being - even temporarily - on Google's servers.


We might end up giving away Adobe Acrobat Pro licenses to every teacher and researcher so they can keep using Moodle as their main platform.


I'm still crossing my fingers, hoping that I'll find a way to make this work before we get there.

In reply to Jeff Noel

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Ken Task -
Picture of Particularly helpful Moodlers

Following is for Linux but think you can adjust ... like the path to your unoconv ... test unoconv by itself

/usr/bin/unoconv -vvv -f pdf [filetoconvert.doc]

The -vvv are verbose levels.

Above is to take 'filetoconvert.doc' and convert a .doc by same filename in same location.

unoconv is a python script so is uno finding python? and is python finding the libreoffice suite called in headless mode to do the doc conversion?

Don't run Windows myself ... sooooooooo.

'spirit of sharing', Ken



In reply to Ken Task

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Jeff Noel -

Hi Ken,


Unoconv works fine by itself (and the output file is valid). Here is the result of the query from your post:

Using office base path: C:\Program Files\LibreOffice
Using office binary path: C:\Program Files\LibreOffice\program
LibreOffice listener successfully started. (pid=2260)
Selected output format: Portable Document Format [.pdf]
Selected office filter: writer_pdf_Export
Used doctype: document
Output file: file:///C:/unoconv/test.pdf

Thanks for your input, and if you have any more suggestions I'm all ears !


Jeff

In reply to Jeff Noel

Re: [3.5.2+] Unoconv on Windows - Blank page and no errors on PDF conversion

by Ken Task -
Picture of Particularly helpful Moodlers

Well, that 'leg' of the whole process checked and worked ... but, test was with what file type submitted?  Unoconv does a bunch but NOT all file types.  See the contents of unoconv itself ... it does list the file types it will do.  

If there is one assignment that has been particularly problematic check what's being submitted.   And let's not put past anything student behavior wise .. I used to have a lot of fun with a "Windows Bigot' with whom I worked ... would send to him as email attachment of a Text file but with extension of .jpeg.  Unlike Linux and Mac's, Windows still dependent upon those extensions.

The next leg, if I re-call correctly, was for the converted file be displayed to grader/teacher.   No logs saying it failed there?

Then the listener would have to clear whatever it just processed and be ready to accept another file for conversion.

Listener isn't really a daemon ... and would sometimes NOT clear and begin anew.

Suggest invesigating how one would watch the listener to see if it functions like it should.   Dunno how one would do that on your platform, however.

Check scheduled task ... think there is one for 'cleaning up' there.   Might a conflict between task and listener doing it's own thing to reset for next.

'spirit of sharing', Ken


Average of ratings: Useful (1)