ncjoes / office-converter

PHP Wrapper for LibreOffice
MIT License
197 stars 75 forks source link

[QUESTION] can this work with windows? #21

Closed HossamElwahsh closed 3 years ago

HossamElwahsh commented 3 years ago

Can this work with windows? Do I need any special setup requirements?

rahmanramsi commented 3 years ago

I create a new class that can handle for windows user

here u can see this, btw I'm using CI3 framework :

`<?php

use NcJoes\OfficeConverter\OfficeConverter;

/* windows user will need this Set Environment for Windows OS

class PDF { public static function convert($pathTarget, $output = false) { /**

paramjotsinghsaini commented 3 years ago

With Some Tweak in constructor we can make this work on windows. ` public function __construct($filename, $tempPath = null, $bin = 'libreoffice', $prefixExecWithExportHome = true) { if(str_contains(PHP_OS, 'WIN')) { $bin = "soffice"; // soffice: libra office window binary $path = storage_path('app/files'); //@$path for file ouput putenv("HOME=".$path); // adding env variable on server } if ($this->open($filename)) { $this->setup($tempPath, $bin, $prefixExecWithExportHome); } }

`

HossamElwahsh commented 3 years ago

Thanks for the help guys