Forum


Replies: 2   Views: 2307
Bug with transformsizes and non-numeric values
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 15-02-2019 - 07:33

Hello,

DOCX to HTML will support nil values in tables in the next release of phpdocx (there's no release date yet).

We recommend you to generate a new class that extends the TransformDocAdvHTMLDefaultPlugin class:

class TransformDocAdvHTMLNewPlugin extends TransformDocAdvHTMLDefaultPlugin

and customize the transformSizes method to handle nil values if needed, for example:

public function transformSizes($value, $source, $target = null)
{
    $returnValue = 0;

    if ($value == 'nil') {
        $value = 0;
    }
...

The transformation classes allow using custom plugins to transform DOCX. For example, if you generate a new class called TransformDocAdvHTMLHRDownloads with the previous change, you can use it without changing the files of the library:

$transformHTMLPlugin = new TransformDocAdvHTMLHRDownloads();

$transform = new Phpdocx\Transform\TransformDocAdvHTML('document.docx');
$html = $transform->transform($transformHTMLPlugin);

You can read more information about extending TransformDocxAdvHTML classes on https://www.phpdocx.com/documentation/introduction/word-to-html-PHP (How to customize transformations section).

Regards.