Skip to content

PreserveText is missing from HTML output #2188

Open
@caugner

Description

@caugner

Describe the Bug

When saving a PhpWord object to HTML, the resulting HTML is missing any text inside a PreserveText container.

Steps to Reproduce

Please provide a code sample that reproduces the issue.

<?php

require __DIR__ . '/vendor/autoload.php';

$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
$section->addPreserveText("This text is missing in the HTML output.");

$tempfile = tempnam(sys_get_temp_dir(), 'phpword');
try {
    $writer = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML');
    $writer->save($tempfile);
    $html = file_get_contents($tempfile);
    echo $html;
} finally {
    unlink($tempfile);
}

Expected Behavior

The text should appear in the HTML.

Current Behavior

The text is missing in the HTML.

Context

Please fill in your environment information:

  • PHP Version: 8.1.1
  • PHPWord Version: v0.18.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions