Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversion from docx to pdf not working on v.1.0.0 #12

Closed
kairiex2 opened this issue Jul 25, 2019 · 6 comments
Closed

Conversion from docx to pdf not working on v.1.0.0 #12

kairiex2 opened this issue Jul 25, 2019 · 6 comments

Comments

@kairiex2
Copy link

Hi..
i'm using office-converter v.1.0.0 installed from composer.
I installed Libre Office 6.2.5.2 x64 on win 10.
Installed ncjoes/office-converter via composer.
Add this code to my php page (for testing) :

convertTo('output-file.pdf'); ?>

and nothing happend. Code seems to stop on "$converter->convertTo('output-file.pdf'); " because all my codes after that not working (not shown on my web page). I tried convert from cmd and it works.
Can U please help. Thanks.

@dudz94
Copy link

dudz94 commented Jul 29, 2019

Hi,

Can you write all of your code ?

If you want an example, in the v1.0.0:

// Load the autoload
require $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
// Use it
use NcJoes\OfficeConverter\OfficeConverter;

// $entirePath is the absolute path of my file I want to convert
$converter = new OfficeConverter($entirePath);
// The file result.pdf will be add to the absolute path you specified just above
$converter->convertTo('result.pdf');

Hope this will help you !

@kairiex2
Copy link
Author

kairiex2 commented Jul 30, 2019

Thanks for your help. This is my code on index.php file.

<?php include_once('../_header.php'); ?>
<div class="container-fluid">
	<?php
		use NcJoes\OfficeConverter\OfficeConverter;
		$converter = new OfficeConverter('lst_st.docx');
		$converter -> convertTo('file.pdf');
	?>
	<h1>Dashboard</h1> 
	<ul>
		<li>
			<p>Welcome</p>
			<p><iframe src="file.pdf" width="100%" height="700" >test view </iframe></p>
		</li>
	</ul>
</div>  
<?php include_once('../_footer.php'); ?>

I put require "_assets/libs/vendor/autoload.php"; on _header.php.
btw I use several module with composer. I didn't configure Libre Office after instal.
File "lst_st.docx" is on same folder as that code page (i put on "dashboard" folder just for testing).
If I comment this code $converter -> convertTo('file.pdf'); the php page is working fine, else the heading and after that is not showing. Is there something I need to configure? Also I have tried the absolute path for my file $converter = new OfficeConverter('http://localhost/dashboard/lst_st.docx');
Also I'm using IIS for testing, not Apache. But the other composer module is working fine though.

@dudz94
Copy link

dudz94 commented Jul 30, 2019

I try your code in my server and it's working fine.

Do you have access to the error_log of the webserver ?
If the line $converter -> convertTo('file.pdf'); doesn't work, the error could help us.

Maybe Libreoffice is not find, for example the binary is not in your $PATH.
There is no configuration to do with Libreoffice after the installation.

Screenshot 2019-07-30 at 15 15 53

@kairiex2
Copy link
Author

kairiex2 commented Jul 31, 2019

Thanks You.
On IIS logs seems there is nothing wrong.
But I found this error on php error logs :

[31-Jul-2019 11:18:39 Asia/Jakarta] PHP Fatal error: Uncaught NcJoes\OfficeConverter\OfficeConverterException: Convertion Failure! Contact Server Admin. in C:\xampp\htdocs\simtu_assets\libs\vendor\ncjoes\office-converter\src\OfficeConverter\OfficeConverter.php:52
Stack trace:
#0 C:\xampp\htdocs\simtu\dashboard\index.php(15): NcJoes\OfficeConverter\OfficeConverter->convertTo('file.pdf')
#1 {main}
thrown in C:\xampp\htdocs\simtu_assets\libs\vendor\ncjoes\office-converter\src\OfficeConverter\OfficeConverter.php on line 52
[31-Jul-2019 11:19:31 Asia/Jakarta] PHP Fatal error: Uncaught NcJoes\OfficeConverter\OfficeConverterException: Convertion Failure! Contact Server Admin. in C:\xampp\htdocs\simtu_assets\libs\vendor\ncjoes\office-converter\src\OfficeConverter\OfficeConverter.php:52
Stack trace:
#0 C:\xampp\htdocs\simtu\dashboard\index.php(15): NcJoes\OfficeConverter\OfficeConverter->convertTo('file.pdf')
#1 {main}
thrown in C:\xampp\htdocs\simtu_assets\libs\vendor\ncjoes\office-converter\src\OfficeConverter\OfficeConverter.php on line 52
[31-Jul-2019 11:19:32 Asia/Jakarta] PHP Fatal error: Uncaught NcJoes\OfficeConverter\OfficeConverterException: Convertion Failure! Contact Server Admin. in C:\xampp\htdocs\simtu_assets\libs\vendor\ncjoes\office-converter\src\OfficeConverter\OfficeConverter.php:52
Stack trace:
#0 C:\xampp\htdocs\simtu\dashboard\index.php(15): NcJoes\OfficeConverter\OfficeConverter->convertTo('file.pdf')
#1 {main}
thrown in C:\xampp\htdocs\simtu_assets\libs\vendor\ncjoes\office-converter\src\OfficeConverter\OfficeConverter.php on line 52

I also check libreoffice install dir and found no libreoffice file (exe/bin). Only filename soffice (exe & bin). I tried commandline convert from example

libreoffice --headless -convert-to pdf fileToConvert.docx -outdir output/path/for/pdf

and its not working. Only after I changed libreoffice to soffice the conversion works.

soffice --headless -convert-to pdf fileToConvert.docx -outdir output/path/for/pdf

Also does this mean on windows system environment variables?

Maybe Libreoffice is not find, for example the binary is not in your $PATH.

Thanks for helping me. I'm new to php and web development, I'm sorry if I'm slow to check on errors.

@dudz94
Copy link

dudz94 commented Jul 31, 2019

Maybe Libreoffice is soffice on Windows. I really dont know the Windows env so I couldn't say...
So the conversion works ? :)

Dont worry, we all started one day !
If I can give you an advise, stop Windows and start a VM in Linux to work with Apache or httpd.

Tell me if you want more info about your issue !

@kairiex2
Copy link
Author

Thank you for the advise. I'm planning to learn linux too, just waiting for a moment after I finished sorting what i've learned on php. Any good advise what linux package is good for web server? I'm really new with all this stuff.
Thank you.

@kairiex2 kairiex2 closed this as completed Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants