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

DOMElement::getAttribute() expects parameter 1 to be string, array given #1369

Closed
1 of 3 tasks
ikraddy opened this issue May 16, 2018 · 8 comments
Closed
1 of 3 tasks

Comments

@ikraddy
Copy link

ikraddy commented May 16, 2018

This is:

I don't know how to read the docx file. I tried to read a docx file that I created, but I made a mistake.

How can I read the text and picture information in the docx file correctly?

<?php
$filename = 'D:\projects/web/mydoc.docx';
$fh = IOFactory::load($filename);

Context

  • PHP version: 7.1.13
  • PHPWord version: 0.14
Error:
Warning: DOMElement::getAttribute() expects parameter 1 to be string, array given in D:\projects\www\test\phpword\vendor\phpoffice\common\src\Common\XMLReader.php on line 140

Fatal error: Uncaught InvalidArgumentException: is not a valid value for PhpOffice\PhpWord\SimpleType\DocProtect, possible values are none, readOnly, comments, trackedChanges, forms in D:\projects\www\test\phpword\src\PhpWord\Shared\AbstractEnum.php:72 Stack trace: 
#0 D:\projects\www\test\phpword\src\PhpWord\Metadata\Protection.php(97): PhpOffice\PhpWord\Shared\AbstractEnum::validate(NULL) 
#1 D:\projects\www\test\phpword\src\PhpWord\Reader\Word2007\Settings.php(112): PhpOffice\PhpWord\Metadata\Protection->setEditing(NULL) 
#2 D:\projects\www\test\phpword\src\PhpWord\Reader\Word2007\Settings.php(71): PhpOffice\PhpWord\Reader\Word2007\Settings->setDocumentProtection(Object(PhpOffice\Common\XMLReader), Object(PhpOffice\PhpWord\PhpWord), Object(DOMElement)) 
#3 D:\projects\www\test\phpword\src\PhpWord\Reader\Word2007.php(94): PhpOffice\PhpWord\Reader\Word2007\Settings->read(Object(PhpOffice\PhpWord\PhpWord)) 
#4 D:\projects\www\test\phpword\src\PhpWord\Reader\Word2007.php(70): PhpOffice\PhpWord\Reader\Word2007->readPart(Object( in D:\projects\www\test\phpword\src\PhpWord\Shared\AbstractEnum.php on line 72
@troosan
Copy link
Contributor

troosan commented May 17, 2018

can you share the mydoc.docx (or any other document that generates this error)?

@ikraddy
Copy link
Author

ikraddy commented May 18, 2018

Thanks,This is a download linkhttps://pan.baidu.com/s/1yQBYqsy6ny87DiR68PIK5Q

@troosan
Copy link
Contributor

troosan commented May 20, 2018

With which program was this document generated? It is missing a lot of xml nodes or attributes that are normally present (although indeed not mandatory).

@troosan
Copy link
Contributor

troosan commented May 20, 2018

@ikraddy please try with the latest dev-develop version, it should be OK

@troosan troosan closed this as completed May 20, 2018
@ikraddy
Copy link
Author

ikraddy commented May 21, 2018

@troosan Thank you very much. This time it will not be an error, but there are problems with the parsed content. The picture in my document seems to be unreadable. It is empty. I use a software called WPS from China.

@kevinfei520
Copy link

kevinfei520 commented May 21, 2018 via email

@ikraddy
Copy link
Author

ikraddy commented May 21, 2018

@Kevin5211314 对呀,WPS

@kevinfei520
Copy link

kevinfei520 commented May 21, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants