Forum


Replies: 7   Views: 4426
Error with pdf generation with new phpdocx pro
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 dlange  · 16-05-2012 - 23:36

Hey,

I just tried out the new version but am not able to generate any PDF files. I always get the following errors:
[code]A PHP Error was encountered
Severity: Warning
Message: ZipArchive::getFromName(): Invalid or unitialized Zip object
Filename: classes/TransformDoc.inc
Line Number: 245[/code]
[code]A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: classes/TransformDoc.inc
Line Number: 248[/code]
[code]A PHP Error was encountered
Severity: Warning
Message: ZipArchive::getFromName(): Invalid or unitialized Zip object
Filename: classes/TransformDoc.inc
Line Number: 285[/code]
[code]A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: classes/TransformDoc.inc
Line Number: 288[/code]
[code]A PHP Error was encountered
Severity: Warning
Message: DOMDocument::loadXML(): Empty string supplied as input
Filename: classes/TransformDoc.inc
Line Number: 370[/code]

Both ZIP and XSL are activated. Any idea on how to fix this?

Best,
Daniel

Posted by admin  · 11-04-2013 - 12:13

Hello,

This is the error:

Invalid or unitialized Zip object

Seems you're not using a valid DOCX file. Please note that a DOCX is a ZIP.

Regards.

Posted by dlange  · 11-04-2013 - 12:13

Hey,

thanks for your fast response. This was my own fault ... had a typo when choosing the docx file. I got another error now instead though. A PDF is generated and automatically downloaded, but it is malformatted. I then checked my log files and found the following error:
[code]<p>Severity: Warning</p>
<p>Message: ZipArchive::extractTo(): Permission denied</p>
<p>Filename: classes/TransformDoc.inc</p>
<p>Line Number: 308</p>[/code]

Do you have any idea what might cause this, and how I can resolve this? I even tried to actually give chmod 777 to the whole PHPDOCX directory and the directory and files I want to convert.

Further, another question (but unrelated to the error above), how can I save the pdf file to the server instead of downloading it directly?

Best,
Daniel

Posted by dlange  · 11-04-2013 - 12:13

By the way, this error occurs when using the following command:
[code]$document = new TransformDoc();
$document->setStrFile('orgfile.docx');
$document->generatePDF();[/code]

I also tried the following command, but there simply nothing happens. No PDF is generated and no error message appears either:
[code]$docx_letter->transformDocx('orgfile.docx', 'newfile.pdf');[/code]

Would appreciate if you could help with this matter. Further, which of these functions should I use if I would like to make use of the new open office powered pdf generation you implemented in 2.5?

[Update]
I now also added the following: $docx_letter->enableCompatibilityMode();
Then I get this error message when using transformDocx: Could not run jodconverter

Posted by dlange  · 11-04-2013 - 12:13

Sorry for spamming, but did a bit more testing. I outputted the executed command and when running this manually from the shell I got the further message: "ERROR: connection failed. Please make sure OpenOffice.org is running and listening on port 8100."

Do I need to install OpenOffice and run this in the background somehow for this to work? Is there anything about this in the documentation?

[Update]
It works when starting OpenOffice in Background with:
[code]soffice --headless --accept="socket,port=8100;urp;" &[/code]

But I could not find anything about this on this page. Is this really necessary, or is the another way?

Best,
Daniel

Posted by admin  · 11-04-2013 - 12:13

[quote][b]Quote from dlange on May 17, 2012, 10:52[/b]
Hey,

thanks for your fast response. This was my own fault ... had a typo when choosing the docx file. I got another error now instead though. A PDF is generated and automatically downloaded, but it is malformatted. I then checked my log files and found the following error:
[code]<p>Severity: Warning</p>
<p>Message: ZipArchive::extractTo(): Permission denied</p>
<p>Filename: classes/TransformDoc.inc</p>
<p>Line Number: 308</p>[/code]

Do you have any idea what might cause this, and how I can resolve this? I even tried to actually give chmod 777 to the whole PHPDOCX directory and the directory and files I want to convert.

Further, another question (but unrelated to the error above), how can I save the pdf file to the server instead of downloading it directly?

Best,
Daniel[/quote]

You're getting this error:

Message: ZipArchive::extractTo(): Permission denied

Please check write access permissions.

Posted by admin  · 11-04-2013 - 12:13

[quote][b]Quote from dlange on May 17, 2012, 12:24[/b]
Sorry for spamming, but did a bit more testing. I outputted the executed command and when running this manually from the shell I got the further message: "ERROR: connection failed. Please make sure OpenOffice.org is running and listening on port 8100."

Do I need to install OpenOffice and run this in the background somehow for this to work? Is there anything about this in the documentation?

[Update]
It works when starting OpenOffice in Background with:
[code]soffice --headless --accept="socket,port=8100;urp;" &[/code]

But I could not find anything about this on this page. Is this really necessary, or is the another way?

Best,
Daniel[/quote]

OpenOffice is used by TransformAdv method to transform DOCX to PDF and other docs format. You can check how to start OpenOffice in TransformDocAdv.php class.

Regards.