Forum


Replies: 8   Views: 4584
Conversion to pdf os x libreoffice
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by hhwebteam  · 11-08-2016 - 21:02

Evening,

I have been trying to convert a simple docx to pdf using libreoffice. I can create the initial docx using the classes but converting does not appear to be working. Please see code below. Am I missing something.

This is the error I am getting when I convert

Warning: rename(./demo_2ad473d4f6f51e1232f00e7724503e10.pdf,demo_conversion_2ad473d4f6f51e1232f00e7724503e10.pdf): No such file or directory in/Applications/XAMPP/xamppfiles/htdocs/securesign/library/phpdocx/classes/TransformDocAdvLibreOffice.inc on line 131

 

Here is the code I am using

    // We instantiate the CreateDocx class in a new object
    require_once 'library/phpdocx/classes/CreateDocx.inc';

    // Create the initial document
    $docx = new CreateDocx();
    $text = 'This is a test document';
    $docx->addText($text); 

    // Save the document
    $fileType = 'pdf';
    $suffix = md5(microtime());
    $filename = 'demo_' . $suffix;
    $docx->createDocx($filename);
    

    $newFilename = 'demo_conversion_'. $suffix .'.' . $fileType;
    $docx = new TransformDocAdvLibreOffice();
    $docx->transformDocument($filename.'.docx', $newFilename, null, array('method' => 'script'));
    unlink($filename . '.docx');

 

Posted by hhwebteam  · 12-08-2016 - 07:38

Hi,

I have created the PDF from the CLI mode no problem running the example1.php file. So it must be a permissions issue. Can you point me in the right direction of where the config folder would be on localhost xampp?

Or whichever folder would be required to complete the conversion so I cna give permissions.

Thanks again

Posted by hhwebteam  · 12-08-2016 - 09:19

Sorry guys does anyone know where in osx localhost you would create the .config folder for libre office to convert pdfs.

I have this working via CLI but from php script it pops libre error and says the application cannot be started an internal error occured? I have tried everything I just need to know where I create the .config file on OSX

Posted by admin  · 12-08-2016 - 09:46

Hello,

It depends on your web server config.

As you can read on http://www.phpdocx.com/documentation/conversion-plugin/debugging-libreoffice (4th item), the directory .config must exists with the right permissions in the root folder of the user that is running the script.
For example, the default config Apache is /var/www in a Linux server, so the correct path is /var/www/.config ; but this may vary for other web servers.

We recommend you to check your web server config to know the root folder of the user's web server or print it using PHP; and check your server logs to check any writing error to any folder.

Regards.

Posted by hhwebteam  · 12-08-2016 - 10:07

Hello,

Thanks for reply I have just got the root of my setup which is /Applications/XAMPP/xamppfiles/htdocs.

Do I just need to create a .config file withing this location with full access rights?

Posted by hhwebteam  · 12-08-2016 - 10:58

I found this in my apache logs

Aug 12 11:51:46 Billys-MacBook-Air soffice[3871]: Persistent UI failed to open file file://localhost/var/root/Library/Saved%20Application%20State/org.libreoffice.script.savedState/window_1.data: Permission denied (13)
 

Posted by admin  · 12-08-2016 - 11:57

Hello,

Please try setting full access (777) to the whole folder (and its contents):

/var/root/Library/Saved%20Application%20State/org.libreoffice.script.savedState

and check is the permission denied go away.

About the folder, we can't guess, so the best approach is to check the web server config and the PHP info.

Regards.

Posted by hhwebteam  · 12-08-2016 - 14:01

Hello,

For anyone having issues with OSX. I managed to resolve with a lot of messing around I had to change the user from deamon to myself and the group to staff in order to resolve.

I then had to disable some services enabled in the php.ini file which the logs where complaining about.