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

Editing an existing doc/docx file. #357

Closed
Akhileshvk opened this issue Sep 1, 2014 · 5 comments
Closed

Editing an existing doc/docx file. #357

Akhileshvk opened this issue Sep 1, 2014 · 5 comments

Comments

@Akhileshvk
Copy link

Akhileshvk commented Sep 1, 2014

Is it possible to edit a existing doc/docx file dynamically using PhpWord (add varying header and footer in all pages which is my requirement). If not can anyone give me some suggestions.

Thanks


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@ghost
Copy link

ghost commented Dec 9, 2014

Yes it's possible with this :
$fileName = "absolutepathtomyfile";
$phpWord = \PhpOffice\PhpWord\IOFactory::load($fileName);

sections = $phpWord->getSections();
$section = $sections[0]; // le document ne contient qu'une section
$arrays = $section->getElements();

@anglo-tech
Copy link

it is not working for doc files

$document = \PhpOffice\PhpWord\IOFactory::load('my.doc');

PHP Error[2]: ZipArchive::getFromName(): Invalid or unitialized Zip object
in file /var/www/m/www/protected/extensions/phpword/PHPWord/Shared/ZipArchive.php at line 198
#0 /var/www/m/www/protected/extensions/phpword/PHPWord/Shared/ZipArchive.php(198): ZipArchive->getFromName()
#1 /var/www/anglo/www/protected/extensions/phpword/PHPWord/Shared/XMLReader.php(59): PhpOffice\PhpWord\Shared\ZipArchiv
->getFromName()
#2 /var/www/m/www/protected/extensions/phpword/PHPWord/Reader/Word2007.php(144): PhpOffice\PhpWord\Shared\XMLReader

getDomFromZip()
#3 /var/www/m/www/protected/extensions/phpword/PHPWord/Reader/Word2007.php(109): PhpOffice\PhpWord\Reader\Word2007-
getRels()
#4 /var/www/m/www/protected/extensions/phpword/PHPWord/Reader/Word2007.php(42): PhpOffice\PhpWord\Reader\Word2007->
eadRelationships()
#5 /var/www/m/www/protected/extensions/phpword/PHPWord/IOFactory.php(73): PhpOffice\PhpWord\Reader\Word2007->load()

@wdog
Copy link

wdog commented Oct 14, 2015

absolute path!

@ankitcodefarm
Copy link

I am working on the same issue and still after giving absolute path still it's not working

@TheSpectroMx
Copy link

@ankitcodefarm apparently it doesn't work with '.doc'. If your file has that extension try to update to '.docx', in my use case it worked like this.

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

5 participants