Forum


Replies: 2   Views: 3337
Paragraph with links in header
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 supriyshah  · 21-06-2013 - 13:46

Hi,



I am trying to add a paragraph with links to header. I am getting a "Document Corrupt" error from MS Word.

If I add the paragraph anywhere else in the document, it works.



Code to add paragraph to document:



<?php

require_once '/phpdocx/classes/CreateDocx.inc';

$docx = new CreateDocx();



$options =array('jc' => 'center', 'font' => 'Calibri', 'lineSpacing' => '0', 'lineSpacing' => 0, 'spacingTop' => 0,

//  'rawWordML' => true

);

$break = array('type' => 'lineBreak');

$companyline3_1 = array('sz'=>'7', 'type' => 'text', 'b' => 'on', 'text' => 'Website: ');

$companyline3_2 = array('type' => 'link', 'URL' => 'http://www.omnitechglobal.com', 'text' => 'http://www.omnitechglobal.com/', 'sz'=>'7');

$companyline4_1 = array('sz'=>'7', 'type' => 'text', 'b' => 'on', 'text' => 'Email: ');

$companyline4_2 = array( 'type' => 'link', 'URL' => 'mailto:gaurav.s@onmitechglobal.com', 'text' => 'gaurav.s@omnitechglobal.com', 'sz'=>'7');

$parameters = array($companyline3_1,$companyline3_2,$break,$companyline4_1,$companyline4_2,$break);

$docx->addParagraph($parameters, $options);

$docx->createDocx('Paragraph_Header_2');

?>





Code to add same paragraph to header:



<?php

require_once '/phpdocx/classes/CreateDocx.inc';

$docx = new CreateDocx();



$options =array('jc' => 'center', 'font' => 'Calibri', 'lineSpacing' => '0', 'lineSpacing' => 0, 'spacingTop' => 0,

  'rawWordML' => true

);

$break = array('type' => 'lineBreak');

$companyline3_1 = array('sz'=>'7', 'type' => 'text', 'b' => 'on', 'text' => 'Website: ');

$companyline3_2 = array('type' => 'link', 'URL' => 'http://www.omnitechglobal.com', 'text' => 'http://www.omnitechglobal.com/', 'sz'=>'7');

$companyline4_1 = array('sz'=>'7', 'type' => 'text', 'b' => 'on', 'text' => 'Email: ');

$companyline4_2 = array( 'type' => 'link', 'URL' => 'mailto:gaurav.s@onmitechglobal.com', 'text' => 'gaurav.s@omnitechglobal.com', 'sz'=>'7');

$parameters = array($companyline3_1,$companyline3_2,$break,$companyline4_1,$companyline4_2,$break);

$finalheader=$docx->addParagraph($parameters, $options);

$headerWordML = $docx->createWordMLFragment(array($finalheader));

$docx->addHeader(array('default' => $headerWordML));

$docx->createDocx('Paragraph_Header_2');

?>



Is this a known bug or am I doing something wrong?


Posted by jorgelj  · 24-06-2013 - 09:45

Hello,



We're checking your issue to be solved.



Regards.