Forum


Replies: 2   Views: 1606
Crash - undefined index: border_top_width
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 vpratfr  · 05-07-2020 - 11:25

Hi,

We use your library to convert HTML to Word documents. On some documents, we see the error :

ErrorException {#159166
  #message: "Undefined index: border_top_width"
  #code: 0
  #file: "/home/vagrant/code/packages/phpdocx/Classes/Phpdocx/Transform/HTML2WordML.php"
  #line: 2197
  #severity: E_NOTICE
  trace: {
    /home/vagrant/code/packages/phpdocx/Classes/Phpdocx/Transform/HTML2WordML.php:2197 {
      Phpdocx\Transform\HTML2WordML->generateTblPr($properties, $attributes)
      › foreach (self::$borders as $key => $value) {
      ›     if (isset($properties['border_' . $value . '_style']) && $properties['border_' . $value . '_color'] != 'none' && $properties['border_' . $value . '_width'] != null) {
      ›         $stringTblPr .= '<w:' . $value . ' w:val="' . $this->getBorderStyles($properties['border_' . $value . '_style']) . '"  w:color="' . $this->wordMLColor($properties['border_' . $value . '_color']) . '" w:sz="' . $this->wordMLLineWidth(isset($properties['border_' . $value . '_width']) ? $properties['border_' . $value . '_width'] : '') . '" />';
    }
    /home/vagrant/code/packages/phpdocx/Classes/Phpdocx/Transform/HTML2WordML.php:975 { …}
    /home/vagrant/code/packages/phpdocx/Classes/Phpdocx/Transform/HTML2WordML.php:1622 { …}

Do you have any hint? I can send the HTML code to a confidential email if needed.

Here is how we create the document:

$docx = new CreateDocx();
$docx->embedHTML(file_get_contents($htmlFile));
$docx->removeHeadersAndFooters();
$docx->createDocx($wordFile);

Regards,