Convert Excel file to PDF using Perl CGI
1
vote
2
answers
1001
views
I'm trying to convert an xlsx file to pdf using Perl CGI (Mason).
Since I did not find a way to convert a file using pure perl, I'm using
soffice
to perform the job.
This works fine until I do it through browser.
The code responsible for conversion is pretty simple:
my @cmd = ( "soffice", "--headless", "--convert-to", "pdf", $filename );
system(@cmd);
This works fine on command line, when ran by a regular user, but running it as Apache user (Mason on Apache), throws an error:
(process:14954): dconf-CRITICAL **: 14:28:42.846: unable to create directory '/usr/share/httpd/.cache/dconf': Permission denied. dconf will not work properly.
Can anyone point me to right direction?
Is there a way to convert xlsx to pdf using just perl, not system commands?
# Edit
To pass dconf
error, I've manually created the directory tree it's complaining about and chowned it to apache user, however, there's next error:
[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!
Warning: failed to read path from javaldx
Same goes if I try unoconv
:
Error: Unable to connect or start own listener. Aborting.
# Solution
Starting unoconv --listener
manually before the operation, does the trick and solves my issue. PDF files are being created.
Asked by Bart
(2314 rep)
Jul 12, 2019, 02:30 PM
Last activity: Jul 12, 2019, 03:11 PM
Last activity: Jul 12, 2019, 03:11 PM