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

Unable to add Textrun element to Title in Word2007 #2375

Open
CyferZ opened this issue Feb 2, 2023 · 0 comments
Open

Unable to add Textrun element to Title in Word2007 #2375

CyferZ opened this issue Feb 2, 2023 · 0 comments

Comments

@CyferZ
Copy link

CyferZ commented Feb 2, 2023

This is a fairly straightforward issue, the title describes what I'm encountering and it's quite easy to replicate.

When creating a TextRun element in a Word document, I am unable to do this:

$section->addTitle($textRun, 3);

The error I encounter is:
TypeError XMLWriter::text(): Argument #1 ($content) must be of type string, PhpOffice\PhpWord\Element\TextRun given.

How I tried adding a TextRun in my Word document:

$exampleTextRun = new \PhpOffice\PhpWord\Element\TextRun();
$exampleTextRun->addText("Title ", 'fontSize9');
$exampleTextRun->addText("colour", ['color' => 'DD0000']);

$section->addTitle($exampleTextRun, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant