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

Converter::pixelToTwip error: Unsupported operand types: string \/ int; #2701

Open
2 tasks
Azamat8405 opened this issue Nov 22, 2024 · 0 comments
Open
2 tasks

Comments

@Azamat8405
Copy link

Azamat8405 commented Nov 22, 2024

Describe the bug and add attachments

When I try parse table from HTML by addHTML method I get error:

"Unsupported operand types: string \/ int",
"../phpoffice\/phpword\/src\/PhpWord\/Shared\/Converter.php": 162
<div style="font-size:17px;">
    <figure class="table" style="width:700px;">
        <table style="border:10px #4c4ce5 ridge;" width="700">
            <tbody>
                <tr>
                    <td style="background-color:#e5e54c;width:100px;"></td>
                    <td style="width:400px;">v</td>
                    <td style="width:200px;">v</td>
                </tr>
                <tr>
                    <td width="100px">v</td>
                    <td style="background-color:#4ce5e5;" width="400px"></td>
                    <td width="200px">v</td>
                </tr>
            </tbody>
        </table>
    </figure>
</div>

Expected behavior

There should be no mistake

Steps to reproduce

 $phpWordInstance    = new PhpWord();
    $phpSectionInstance = $phpWordInstance->addSection([
        'orientation'  => 'landscape',
        'marginLeft'   => (int)round(20 * 56.6929133858),
        'marginRight'  => (int)round(20 * 56.6929133858),
        'marginTop'    => (int)round(20 * 56.6929133858),
        'marginBottom' => (int)round(20 * 56.6929133858),
    ]);

    $html = '<div style="font-size:17px;">
                <figure class="table" style="width:700px;">
                    <table style="border:10px #4c4ce5 ridge;" width="700">
                        <tbody>
                            <tr>
                                <td style="background-color:#e5e54c;width:100px;"></td>
                                <td style="width:400px;">v</td>
                                <td style="width:200px;">v</td>
                            </tr>
                            <tr>
                                <td width="100px">v</td>
                                <td style="background-color:#4ce5e5;" width="400px"></td>
                                <td width="200px">v</td>
                            </tr>
                        </tbody>
                    </table>
                </figure>
            </div>';

    Html::addHtml($phpSectionInstance, $html, false, false);

    $fqName = new PhpOffice\PhpWord\Writer\Word2007($phpWordInstance);
    $fqName->save('./t.docx');

PHPWord version(s) where the bug happened

1.3

PHP version(s) where the bug happened

8

Priority

  • I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
  • I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)
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