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

How can I read and write to a docx file with PHPWord? #2365

Open
richardsonoge opened this issue Jan 2, 2023 · 1 comment
Open

How can I read and write to a docx file with PHPWord? #2365

richardsonoge opened this issue Jan 2, 2023 · 1 comment

Comments

@richardsonoge
Copy link

Here is my problem with PHPWord::

At first I wanted to convert my doc file to docx. Now I found a copy() function that gives me the possibility to transform it into a docx file. Now I would like to take the content of this file, translate it and write the url of my site at the beginning of the file. I have found many scripts that tell me what to do. But every time I try to use these scripts, they give me an error. For example, I wanted to convert my document to a docx file, but it gives me this error:

Steps to Reproduce

Please provide a code sample that reproduces the issue.

$fileUrl = '../docs.bloggors.com/docs/bb8bee21e252e84820e0c9308a36bc09.doc';

require_once 'vendor/autoload.php';

if (is_readable($fileUrl)) {
    echo 'The file is available for readinge';
} else {
    echo 'The file is not accessible for reading !';
}

$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($fileUrl);
$templateProcessor->setValue('name', 'myvar');
$templateProcessor->saveAs('oge.docx');

This is what I expect from you guys

Can you help me to be able to transform a doc file into a docx file or to write, modify and add text correctly in the file I created and transformed with the copy() function please?

Please fill in your environment information:

  • PHP Version: 7.4
  • PHPWord Version: 1.0.0
@MarkBaker
Copy link
Member

Pull the file to the local filesystem, and then open it. PhpWord works from the filesystem, not from remote streamed files, because remote streaming doesn't support seek()

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

No branches or pull requests

2 participants