1

So I want to add an header image to my document in PHPWord in Laravel. So this is my code

public function generateDocx()
{
    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $section = $phpWord->addSection();

    $headerLogo = 'http://127.0.0.1:8000/img/logoAnevBulanan.png';
    $section->addImage($headerLogo);

    // Bunch of line to download the docx
}

And I got Maximum execution time of 60 seconds exceeded, when I try the other method from the documentation, I still got the same error. I try to use asset() helper from laravel and still did not work

1 Answer 1

2

Try getting your image using local path instead of URL

$source = file_get_contents('/path/to/my/images/earth.jpg');
$textrun->addImage($source);

Refer to documentation : https://phpword.readthedocs.io/en/latest/elements.html#images

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.