Bug #73605 [Fbk->Opn]: COM Word.application SaveAs Type conflict
| From: | tt at prof4 dot net | Date: | Fri, 25 Nov 2016 14:16:36 +0000 |
| Subject: | Bug #73605 [Fbk->Opn]: COM Word.application SaveAs Type conflict | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205637@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73605&edit=1
ID: 73605
User updated by: tt at prof4 dot net
Reported by: tt at prof4 dot net
Summary: COM Word.application SaveAs Type conflict
-Status: Feedback
+Status: Open
Type: Bug
Package: COM related
Operating System: Windows 10 Pro Apache 2.4
PHP Version: 7.0.13
Block user comment: N
Private report: N
New Comment:
Its quite hard to test with another Word-Version ...
It doesnt matter which file you use. You can test it with every *.doc, *.rtf, it will not be
converted to another format.
Every time the same message.
Previous Comments:
------------------------------------------------------------------------
[2016-11-25 14:05:02] ab@php.net
Does it make a difference, when another word document is used? Or another Office version? Please
supply a test file in that case.
Thanks.
------------------------------------------------------------------------
[2016-11-25 09:44:10] tt at prof4 dot net
moved from PDF functions to COM related
------------------------------------------------------------------------
[2016-11-25 09:22:33] tt at prof4 dot net
Description:
------------
I am not sure if this is relating to the topic of "PDF functions". We tested the following
script with PHP5.4 and PHP7. It works perfectly with PHP5.4 but generates an error in PHP7 (Same
configuration for the environment but the Port for Apache24 is different to the port for Apache22
with PHP5.4)
We also tested it with the SaveAs2 function and also we checked the parameters for
"Open()".
We are using Word Version 14.
Test script:
---------------
function rtf2pdf($path) {
if (!class_exists('COM')) {
return false;
}
$word = new COM("word.application");
if (!$word) {
return false;
}
if ($word->Version < 12) {
$word->Quit();
return false;
}
$word->Documents->Open($path, false, true);
$wdSaveFormats = array(
'docx' => 16,
'html' => 10,
'rtf' => 6,
'txt' => 2,
'doc' => 0,
'pdf' => 17
);
$new_file = str_replace('.rtf', '.pdf', $path);
$word->ActiveDocument->SaveAs($new_file, $wdSaveFormats['pdf']);
$word->ActiveDocument->SaveAs2($new_file, $wdSaveFormats['pdf']);
$word->ActiveDocument->Close(false);
$word->Quit();
return $new_file;
}
echo rtf2pdf('C:\\mydoc.rtf');
Expected result:
----------------
C:\mydoc.pdf
Actual result:
--------------
Fatal error: Uncaught com_exception: Parameter 0: Typenkonflikt. in rtftest.php:24 Stack trace: #0
rtftest.php(24): variant->SaveAs('C:\\mydoc.pdf', 17) #1 rtftest.php(31):
rtf2pdf('C:\\mydoc.rtf') #2 {main} thrown in rtftest.php on line 24
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73605&edit=1